robbederks / downzip

NPM library to enable client-side code to stream potentially large files into a zipped download
MIT License
35 stars 12 forks source link

is this based on jzip #11

Closed ricky11 closed 3 years ago

ricky11 commented 3 years ago

Hi.

Thanks for this library, trying to get it going ...

this is based on jszip correct? which means it does support large (more than 4gb) zips?

I set up the service worker using

await navigator.serviceWorker.register('downzip-sw.js'); no error is thrown after this line.

but i keep getting the error when i try to download the file.

main.js?9aaa:1 [DownZip-Main] [DownZip] No service worker registered!

Does this s support ie11? Does it download the remote url first and then create a zip on the client? or does it stream download and create the zip at the same time? which means the client isn't waiting for a progress.

ricky11 commented 3 years ago

just updating this issue; why use service worker instead of a web worker, do we need to cache the zip file ? or just use another process for the background task, in this case a web worker would be better no?

robbederks commented 3 years ago

this is based on jszip correct? which means it does support large (more than 4gb) zips? It's not based on jszip, it's a completely custom implementation (see https://github.com/robbederks/downzip/tree/master/src/zip).

It does support zip files over 4GB though, it has the option to use the zip64 standard.

I set up the service worker using await navigator.serviceWorker.register('downzip-sw.js'); no error is thrown after this line. but i keep getting the error when i try to download the file. main.js?9aaa:1 [DownZip-Main] [DownZip] No service worker registered!

Just creating an instance of the DownZip class should be enough to register the service worker. No need to register it yourself, which also wouldn't work since it has state on whether it has been registered or not. Please see the example in the README

Does this s support ie11?

Not sure, haven't tested. Probably.

Does it download the remote url first and then create a zip on the client? or does it stream download and create the zip at the same time? which means the client isn't waiting for a progress.

It streams the download, streams the zipping and also streams the final download to your PC, which makes that it doesn't have to hold anything in RAM, and should be on a background thread due to the service worker.

just updating this issue; why use service worker instead of a web worker, do we need to cache the zip file ? or just use another process for the background task, in this case a web worker would be better no?

Been a long time since I wrote this, but I'm retty sure that a service worker is the only way to achieve the streaming processing while downloading, which is the basis of this library's design.