Skip to content

Instantly share code, notes, and snippets.

@noelvo
Created December 6, 2015 23:22
  • Star 53 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save noelvo/4502eea719f83270c8e9 to your computer and use it in GitHub Desktop.
Download multiple files then compress to one zip file using JSZip & JSZip-utils
var zip = new JSZip();
var count = 0;
var zipFilename = "zipFilename.zip";
var urls = [
'http://image-url-1',
'http://image-url-2',
'http://image-url-3'
];
urls.forEach(function(url){
var filename = "filename";
// loading a file and add it in a zip file
JSZipUtils.getBinaryContent(url, function (err, data) {
if(err) {
throw err; // or handle the error
}
zip.file(filename, data, {binary:true});
count++;
if (count == urls.length) {
var zipFile = zip.generate({type: "blob"});
saveAs(zipFile, zipFilename);
}
});
});
@Ishaan28malik
Copy link

I just created a new App using the multiple-file-downloader

Here

https://github.com/Ishaan28malik/react-zip-download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment