Get the file through websocket and start the download dialog

my HTML5 web application receives the file as binary data via websocket. Is there a way to initiate a file upload dialog (via javascript) to save the received data to the user's disk?

Thanks!

+6
source share
2 answers

You need to build dataUri and open a new window with it. Specific mimetypes can trigger the browser to automatically save in a dialog box.

Example uri data: "data:application/octet-stream,base64" + base64binary

+4
source

Not yet, no. The new File API currently covers read-only. Update : see Peter's answer , if you need to do this only on (and today, not IE) browsers , where you can do it using the URI data: scheme.

The usual way to do this is to get the file via HTTP into a hidden iframe using Content-Disposition: attachment to start the file download dialog, rather than receiving it through a web socket.

0
source

Source: https://habr.com/ru/post/911665/


All Articles