Open callumlocke opened 10 years ago
Having the same error with a 15MB zip file. Did you find a workaround for this?
I'm also having the same issue. Did either of you folks figure out what the problem was? My zip file is about 20mb.
I end up using decompress to unzip my files :(
Experiencing the same thing with a 2.7 MB file. I was pulling the file off a server programmatically, and periodically they update the zip (presumably the same process each time), and now it doesn't work. I can open it with Windows just fine, however.
Same. Bummer.
I also started having this issue. The problem started when I deployed to an AWS server - the same zip files uncompress without error during local testing.
It must have something to do with specific Node configurations.
This project is abandonware so I doubt this will be resolved. I'm using Adm-Zip now and it works well. decompress seems like a decent option too.
Bumping into this too.
The problem isn't in the unzip library. You were probably using the createReadStream method of the S3 getObject response. This seems to pack an http header in front of the zip file, which causes unzip to rightfully complain about this not being a zip file with the aforementioned error.
Solution is to take the Body of the response, which is a Buffer, convert that to a ReadStream and pipe it into unzip. The BufferStream converter class can be found here: https://gist.github.com/bennadel/b35f3a15cb3b03ddbcf8#file-test-js . (No idea why this isn't available as a npm package)
So my solution then looks as follows (loose code snippet):
var s3 = new AWS.S3();
var params = {Bucket: s3bucket, Key: zipFileName};
s3.getObject(params,function(err, queryData) {
if (err){
return reject("Loading file "+s3bucket+" : "+zipFileName+" failed. "+err);
}
else{
var stream=new BufferStream(queryData.Body);
var unzipStream=stream.pipe(unzip.Parse());
unzipStream.on('error', function(err){ return reject("Unzipping file "+s3bucket+" : "+zipFileName+" failed. "+err); });
unzipStream.on('entry', function (entry) {
...
Hope this helps others with this issue.
@MaximilianBuegler can you explain what you mean by
This seems to pack an http header in front of the zip file, which causes unzip to rightfully complain about this not being a zip file with the aforementioned error.
Are you saying when you read the S3 getObject stream it first writes a an HTTP header before the actual body of the object? Surely this can't be true. The library would be completely broken if this were the case.
For anyone who is looking for an answer. I accidentally bumped into this repo (maintainable fork of this one) https://github.com/ZJONSSON/node-unzipper I just replaced my dependency and require line and everything worked like a charm.
When trying to unzip a large archive (about 45MB that should expand to about 100MB), it fails with this output:
Any idea what this means?