+ 2

Multiple blobs to single zip file with JSzip?

i try to download multiple images with single ZIP file but i get the opposite. Which is to download zip files but they come in separated zip files . And when i console log the urls[] array they come in different arrays . const fileURLs = window.URL.createObjectURL(result);// that is blob var zip = new JSZip(); var count = 0; var zipFilename = "Selective.zip"; var urls = [ // i try to make them array fileURLs ]; console.log(urls); urls.forEach(function(url){ var filename = result.name; // 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++; zip.generateAsync({type:'blob'}).then(function(content) { saveAs(content, zipFilename); }); }); });

5th Jan 2022, 4:06 PM
Alev Mustafa
1 Antwort
- 2
Man, I did that few years back, 2019, but I can't help you. What I can say that this JS is not great! Even is the most popular programming language in the world, I tell you, is not great. Good news, you can always find solutions on the internet. That's how I found that solution for archive download. Good luck!
5th Jan 2022, 4:35 PM
Romeo Cojocaru
Romeo Cojocaru - avatar