使用javascript下载大数据流(> 1Gb) [英] Download large data stream (> 1Gb) using javascript

查看:130
本文介绍了使用javascript下载大数据流(> 1Gb)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以将数据从javascript流式传输到浏览器的下载管理器

I was wondering if it was possible to stream data from javascript to the browser's downloads manager.

使用webrtc,我流数据(从文件> 1Gb)从浏览器到另一个。在接收器端,我将所有这些数据存储到内存中(作为arraybuffer ...所以数据基本上仍然是块),我希望用户能够下载它。

Using webrtc, I stream data (from files > 1Gb) from a browser to the other. On the receiver side, I store into memory all this data (as arraybuffer ... so the data is essentially still chunks), and I would like the user to be able to download it.

问题: Blob对象的最大大小约为600 Mb(取决于浏览器),因此我无法从块中重新创建文件。有没有办法流式传输这些块,以便浏览器直接下载它们?

Problem : Blob objects have a maximum size of about 600 Mb (depending on the browser) so I can't re-create the file from the chunks. Is there a way to stream these chunks so that the browser downloads them directly ?

推荐答案

按照@ guest271314的建议,我添加了 StreamSaver.js 到我的项目,我成功收到大于1GB的文件铬。根据文档,它应该适用于高达15GB的文件,但我的浏览器在此之前崩溃了(我的最大文件大小约为4GB)。

Following @guest271314's advice, I added StreamSaver.js to my project, and I successfully received files bigger than 1GB on Chrome. According to the documentation, it should work for files up to 15GB but my browser crashed before that (maximum file size was about 4GB for me).

注意我:为了避免Blob max size限制,我还尝试手动将数据附加到< a>< / a> 的href字段,但它失败的文件大约600MB ...

Note I: to avoid the Blob max size limitation, I also tried to manually append data to the href field of a <a></a> but it failed with files of about 600MB ...

注意II:看起来很惊人,使用 createObjectURL 在Firefox上可以完美地处理高达4GB的文件!!

Note II: as amazing as it might seem, the basic technic using createObjectURL works perfectly fine on Firefox for files up to 4GB !!

这篇关于使用javascript下载大数据流(&gt; 1Gb)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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