通过websocket接收文件并启动下载对话框 [英] receive file via websocket and initiate download dialog

查看:539
本文介绍了通过websocket接收文件并启动下载对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTML5网络应用程序通过websocket接收文件作为二进制数据。有没有办法启动文件下载对话框(通过javascript)将接收的数据保存到用户磁盘?



谢谢!

解决方案

您需要构建一个dataUri并打开一个新的窗口。具体的mimetype可以触发浏览器的自动保存为对话框。



示例数据uri:data:application / octet-stream,base64+ base64binary


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 the users disk?

Thank you!

解决方案

You need to build a dataUri and open a new window with this. Specific mimetypes can trigger the browser's automatic save as dialog.

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

这篇关于通过websocket接收文件并启动下载对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆