File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -187,16 +187,24 @@ class VirtualNetworkInterface {
187187 break ;
188188
189189 case MessageType . FileDownload :
190- const blob = new Blob ( [ msg . data as Uint8Array ] ) ;
191- const url = URL . createObjectURL ( blob )
192- if ( Median . isNativeApp ( ) ) {
193- Median . share . downloadFile ( { url, filename : "out.pcap" } ) ;
194- } else {
195- const a = document . createElement ( "a" ) ;
196- a . href = url ;
197- a . download = "out.pcap" ;
198- a . target = "_blank" ;
199- a . click ( ) ;
190+ if ( ! ( msg . data instanceof Uint8Array ) ) {
191+ console . error ( "Expected Uint8Array for FileDownload message, got" , msg . data ) ;
192+ break ;
193+ }
194+ {
195+ const copy = new Uint8Array ( msg . data . length ) ;
196+ copy . set ( msg . data ) ;
197+ const blob = new Blob ( [ copy . buffer ] , { type : 'application/vnd.tcpdump.pcap' } ) ;
198+ const url = URL . createObjectURL ( blob ) ;
199+ if ( Median . isNativeApp ( ) ) {
200+ Median . share . downloadFile ( { url, filename : "out.pcap" } ) ;
201+ } else {
202+ const a = document . createElement ( "a" ) ;
203+ a . href = url ;
204+ a . download = "out.pcap" ;
205+ a . target = "_blank" ;
206+ a . click ( ) ;
207+ }
200208 }
201209 break ;
202210
You can’t perform that action at this time.
0 commit comments