2 回答
TA贡献1860条经验 获得超8个赞
function compressed_img(urls,nombre) {
var zip = new JSZip();
var count = 0;
var name = `${nombre}.zip`;
var givenName = `test`;
var counter = 1;
urls.forEach(function(url){
JSZipUtils.getBinaryContent(url, function (err, data) {
console.log(data)
if(err) {
throw err;
}
var extention = url.split('.').pop();
zip.file(`${givenName}${counter}.${extention}`, data, { binary: true, createFolders: true });
count++;
counter++;
if (count == urls.length) {
zip.generateAsync({type:'blob'}).then(function(content) {
saveAs(content, name);
});
}
});
});
}
添加回答
举报