kevva / download

Download and extract files
MIT License
1.28k stars 200 forks source link

Downloading a large file throws `Array buffer allocation failed` #138

Closed yuxiaoyan1205 closed 7 years ago

yuxiaoyan1205 commented 7 years ago

download--http://192.168.2.237:8899/ZIP/5975681569e5f4941e595640.zip--failed--RangeError : Array buffer allocation failed

kevva commented 7 years ago

That's because you're running out of memory. We're storing the file in memory if you're using the Promise based API. Try using streams instead:

download('unicorn.com/foo.zip').pipe(fs.createWriteStream('foo.zip'));
yuxiaoyan1205 commented 7 years ago

Hi,kevva: I use streams:download('unicorn.com/foo.zip').pipe(fs.createWriteStream('foo.zip')); but it is still error: image The size of this zip package is 1.2G。

kevva commented 7 years ago

Are you running this in the browser?

yuxiaoyan1205 commented 7 years ago

yes

kevva commented 7 years ago

I'm pretty sure that won't work. This package is intended for use in Node.js.

yuxiaoyan1205 commented 7 years ago

OK,thanks