Comments (11)
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.
from node-unzip.
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.
from node-unzip.
Having the same error with a 15MB zip file. Did you find a workaround for this?
from node-unzip.
I'm also having the same issue. Did either of you folks figure out what the problem was? My zip file is about 20mb.
from node-unzip.
I end up using decompress to unzip my files :(
from node-unzip.
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.
from node-unzip.
Same. Bummer.
from node-unzip.
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.
from node-unzip.
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.
from node-unzip.
Bumping into this too.
from node-unzip.
@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.
from node-unzip.
Related Issues (20)
- enhancement: Set option for deletion
- `me.error` is not a function HOT 1
- Error: invalid signature: 0x6064b50 HOT 2
- When using with typescript,the process may crash HOT 1
- Pipe signature on Entry
- Error: invalid signature: 0x70a4935 HOT 1
- Please remove dependency on 'natives HOT 5
- Does not work with nodejs v10.0.0 HOT 5
- Don't use under electron-main HOT 3
- extracted files corrupted HOT 1
- folder as file HOT 1
- DO NOT USE THIS THING HOT 8
- Not working with Node 12, primordials is not defined HOT 4
- Mode not preserved with Extract
- Update fstream to a secure version HOT 5
- Any way to pass in arguments like -j or -d from normal unzip?
- Dependency needs updating
- How to stop decompressing zip?
- primordials HOT 2
- unzipper.Parse doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-unzip.