gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.38k stars 510 forks source link

nodejs V16 => ReferenceError: Response is not defined #419

Closed gowy222 closed 1 year ago

gowy222 commented 1 year ago

const zipReader = new zip.ZipReader(readable)

ERR: reader = new BlobReader(await new Response(reader.readable).blob()); //put all data into memory? if file over 2GB.. => ReferenceError: Response is not defined


Response is Web API? is there any way work with big file(>2GB) use fs.createReadStream(local_path)... low memory! ; and noted NO Readable.toWeb() in pure nodejs tho..

gildas-lormeau commented 1 year ago

If you cannot web streams natively, you can write a class extending the class Reader. The method readUint8Array in this class should rely on fs.createReadStream and use the options start, end in order to read sections of the file, see https://nodejs.org/api/all.html#fs_fs_createreadstream_path_options. There is an example of custom Reader class in the documentation or here: https://github.com/gildas-lormeau/zip.js/blob/151b5984728dddad42f2f87da39b1efc9b9b7519/tests/all/test-custom-io.js.