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

Support for direct download (no-zip) of individual URLs #21

Closed BoPeng closed 1 year ago

BoPeng commented 3 years ago

Many thanks for creating this tool, which should help our users download multiple files from our website.

I have a somewhat strange request though: can downzip be extended to support downloading a single file without creating a zip? The reason for this is that we store our data on another host so chrome disallows direct download from the URL. Whereas downzip allows us to download multiple files from the host, it would be convenient for our users to download a single file using the same mechanism. I suppose the logic could be like

  1. If files contains multiple files, use .zip
  2. if files contains a single file and zipFileName is unspecified or does not end with .zip, download in original format.
robbederks commented 3 years ago

Seems pretty straightforward to implement. Would maybe gate this behind a parameter when downzip is instantiated which defaults to false. Would merge if it's a clean PR!

BoPeng commented 3 years ago

I found https://github.com/jimmywarting/StreamSaver.js which shares the same "stream" idea and appears to provide what I need. I would love to have one less dependency if downzip can handle both cases but I am afraid that my level of JS is not enough to provide a PR to downzip, maybe testing and documentation if you can lead the effort.

robbederks commented 3 years ago

I'm sorry, I don't have the time at the moment to implement this. Will leave it open for if anyone else is interested!

BoPeng commented 3 years ago

Maybe you can just outline, in a few sentences, where changes should be made?

robbederks commented 1 year ago

Closing due to inactivity. As mentioned, should be trivial to implement and would merge a PR to do this.