Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load large local files using JavaScript?

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.

like image 358
Damien Golding Avatar asked Feb 24 '26 16:02

Damien Golding


1 Answers

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.

like image 176
hoangfin Avatar answered Feb 26 '26 06:02

hoangfin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!