Stuk / jszip-utils

Other
228 stars 193 forks source link

getBinaryContent : handle multiple urls at once #7

Open dduponchel opened 9 years ago

dduponchel commented 9 years ago

Downloading more than one file is common (like in the JSZip downloader example).

getBinaryContent could take an array of urls :

JSZipUtils.getBinaryContent(["path1", "path2"], function (err, dataArray) {...})

See also Stuk/jszip#168.

abitdodgy commented 8 years ago

Is it not possible to download a zip that consists of multiple remote files? We have a usecase where users select multiple files and request a download. We'd rather not implement this on the server, if at all possible.

dduponchel commented 8 years ago

You mean a split zip file ? JSZip doesn't support them.

abitdodgy commented 8 years ago

@dduponchel not a split zip, rather a single zip file that has several files download from a remote location. So, let's say I have three files a, b, and c.jpg hosted on S3, I would like to create a single zip file images.zip that contains all three files. Is that possible? Or is it a one file per zipped file only?

dduponchel commented 8 years ago

JSZipUtils.getBinaryContent handles one file per call, but you can call it several times to fill in a zip object, see http://stuk.github.io/jszip/documentation/examples/downloader.html for example.

noelvo commented 8 years ago

@abitdodgy I guess you have figured out how to solve the problem of download multiple files and zip to 1 file. Here is how I do it https://gist.github.com/noelvo/4502eea719f83270c8e9. I am wondering how you implemented.

abitdodgy commented 8 years ago

@noelvo in the end I use d a Ruby library to stream the files from the CDN. It's worked well for me, especially because I needed to do some server side processing before streaming the file back the user.

chenster commented 8 years ago

It's a problem I think due to the nature of ajax call being async. A lot times you get empty zip file before content from Ajax was even returned.