Is there a way to handle very large files(like 2GB and over) locally in JavaScript without crashing the browser?
*I am aware of the input tag and the FileReader API, but it seems there is nothing like Node.js streams.
Is there a way to handle very large files(like 2GB and over) locally in JavaScript without crashing the browser?
*I am aware of the input tag and the FileReader API, but it seems there is nothing like Node.js streams.
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 is a good example.
slice()
method of Blob. readAsArrayBuffer will just crash the browser the same if you pass a too big Blob to it. –
Typist © 2022 - 2024 — McMap. All rights reserved.