Stuk / jszip

Create, read and edit .zip files with Javascript
https://stuk.github.io/jszip/
Other
9.73k stars 1.3k forks source link

Can JSZip unpack a compressed string? #534

Open davemerrill opened 6 years ago

davemerrill commented 6 years ago

I have JSON files with a base64 encoded JSON string in zip format inside them. I need that inner JSON object, in a browser. Java's InflatorInputStream can unpack it on the server, so it actually is in zip format.

However, trying to decompress it with JSZip gives "Uncaught (in promise) Error: Can't find end of central directory : is this a zip file ?". I'm not sure I understand that error, but the obvious explanation is that it's not a compressed file system, just a compressed string.

Can JSZip inflate that? How?

Here's what I tried, with an empty promise handler: new JSZip().loadAsync(binaryData).then(function(zip) {});

davemerrill commented 6 years ago

Nevermind, this works perfectly: pako.inflate(binaryData, { to: 'string' })

rushglen commented 4 years ago

Doesn't work for me... could you explain how you derive "binaryData"? Thanks, (Cannot find a way to inflate (decompress) a zip file made with jszip).