var zip = new JSZip();
// Add a text file with the contents "Hello World
"
zip.file("Hello.txt", "Hello World
");
// Add a another text file with the contents "Goodbye, cruel world
"
zip.file("Goodbye.txt", "Goodbye, cruel world
");
// Add a folder named "images"
var img = zip.folder("images");
// Add a file named "smile.gif" to that folder, from some Base64 data
img.file("smile.gif", imgData, {base64: true});
zip.generateAsync({type:"base64"}).then(function (content) {
location.href="data:application/zip;base64," + content;
});