Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
generateAndDownloadZipFile_() {
let filename = this.zipFilename_ || 'output.zip';
if (!this.fileSpecs_.length) {
return;
}
this.isGenerating_ = true;
this.updateUI_();
let zip = new JSZip();
this.fileSpecs_.forEach(fileSpec => {
if (fileSpec.canvas) {
zip.file(fileSpec.name, fileSpec.canvas.toDataURL().replace(/.*?;base64,/, ''), {base64: true});
} else {
zip.file(fileSpec.name, fileSpec.textData);
}
});
zip.generateAsync({type: 'blob'}).then(blob => {
Util.downloadFile(blob, filename);
this.isGenerating_ = false;
this.updateUI_();
}).catch(error => {
console.error(error);
this.isGenerating_ = false;