如何使用 JavaScript 加载大型本地文件?
How to load large local files using JavaScript?
有没有一种方法可以在 JavaScript 中本地处理非常大的文件(如 2GB 及以上)而不会使浏览器崩溃?
*我知道输入标签和 FileReader API,但似乎没有 Node.js 流。
FileReader enables you to read contents of files asynchronously. With respect to large file (2GB in your case), you can use function/method FileReader.readAsArrayBuffer()
to read a certain chunk size of a file in the memory hence this won't crash your browser, this blog 就是一个很好的例子。
有没有一种方法可以在 JavaScript 中本地处理非常大的文件(如 2GB 及以上)而不会使浏览器崩溃?
*我知道输入标签和 FileReader API,但似乎没有 Node.js 流。
FileReader enables you to read contents of files asynchronously. With respect to large file (2GB in your case), you can use function/method FileReader.readAsArrayBuffer()
to read a certain chunk size of a file in the memory hence this won't crash your browser, this blog 就是一个很好的例子。