Jszip: generateAsync does not work on Node.js 6.2.2

Created on 23 Jun 2016  Â·  5Comments  Â·  Source: Stuk/jszip

The generateAsync method does not work on Node.js 6.2.2. Then promise that is returned is never called.

A demonstration: https://www.youtube.com/watch?v=HMXykAhBfuM&feature=youtu.be .

Test code:

var JSZip = require('jszip');

try {
  var zip = new JSZip();
  zip.file("Hello.txt", "Hello World\n");
  console.log('Start generateAsync');

  zip.generateAsync({type: "blob"})
    .then(function (content) {
      console.log('Stop generateAsync');
      console.log(content);
    });
} catch (ex) {
  console.log(ex);
}

Most helpful comment

There was no error given by jszip. Apparently blob is not supported on my platform. I solved this issue by using the type nodebuffer.

All 5 comments

There was no error given by jszip. Apparently blob is not supported on my platform. I solved this issue by using the type nodebuffer.

This issue can be closed

from where i should find the type nodebuffer. thanks and regards

Hello, I am using node 6.11.1 and trying to zip an array of links, but it so happens that sometimes it zips the complete ones but sometimes, it does not do for all the links.

Any help or redirect to links would be helpful. Thanks

I am using jszip in salesforce.com and i am getting same error and here is the code

saveData : function(data, fileName, helper) {
var attachments = data.attachments;
var zip = new JSZip();
var csv = helper.convertArrayOfObjectsToCSV(data.contentDocumentLinks);
alert(data.contentDocumentLinks);
zip.file("Attachments.csv", csv);
var attachmentsFolder = zip.folder("Attachments");
for(var i=0;i attachmentsFolder.file(attachments[i].docId + '_' +attachments[i].title + '.' + attachments[i].ext, attachments[i].data, {base64: true});
}
zip.generateAsync({type:"blob"}).then(function(content) {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
var url = window.URL.createObjectURL(content);
a.href = url;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(url);
$A.get("e.force:closeQuickAction").fire()

    });
},

can you please help me with this

Was this page helpful?
0 / 5 - 0 ratings