receive file via websocket and initiate download dialog

后端 未结 2 803
故里飘歌
故里飘歌 2020-12-15 11:14

my HTML5 web application receives a file as binary data via a websocket. Is there any way to initiate a file download dialog (via javascript) to save the received data to th

2条回答
  •  伪装坚强ぢ
    2020-12-15 11:41

    Not yet, no. The new File API currently only covers reading. Update: See Peter's answer if you only need to do this on cutting-edge (and to date, non-IE) browsers, where you can do it with the data: URI scheme.

    The usual way to do this would be to receive the file via HTTP into a hidden iframe using Content-Disposition: attachment to trigger the file download dialog, rather than receiving it via a web socket.

提交回复
热议问题