简体   繁体   English

如何将文件切成碎片并在Javascript FileApi中还原

[英]How do I slice a file to pieces and restore it in Javascript FileApi

I'm trying to create ajax file upload but I have encountered an error with it, when you upload a file that is larger than for example:800MB google chrome crash. 我正在尝试创建ajax文件上传,但是当您上传的文件大于例如800MB谷歌浏览器崩溃时,我遇到了一个错误。

So I thought to cut it into pieces and then restore it,but how do I do this? 所以我想把它切成碎片然后再恢复,但是我该怎么做呢?

You need to use javascript FileReader API that helps to create chunks and send it to the server. 您需要使用javascript FileReader API,该API可以帮助创建块并将其发送到服务器。 The mechanism is simple but if you are using small chunk size chrome might crash again if you are uploading asynchronously because of the looping through all the chucks. 该机制很简单,但是如果您使用小块大小的Chrome,则由于循环通过所有卡盘,因此如果异步上传,则chrome可能会再次崩溃。

Which you can solve the by using Webworkers, Javascript Webworkers acts as separate threads and finally use Websockets if possible. 您可以使用Webworkers解决此问题,而Javascript Webworkers充当单独的线程,并在可能的情况下最终使用Websocket。

Few Resources to implement all the 几乎没有资源可以实施所有

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM