Git Product home page Git Product logo

Comments (11)

coockoo avatar coockoo commented on July 16, 2024 8

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.

MaximilianBuegler avatar MaximilianBuegler commented on July 16, 2024 1

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.

molant avatar molant commented on July 16, 2024

Having the same error with a 15MB zip file. Did you find a workaround for this?

from node-unzip.

alarner avatar alarner commented on July 16, 2024

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.

molant avatar molant commented on July 16, 2024

I end up using decompress to unzip my files :(

from node-unzip.

richdunajewski avatar richdunajewski commented on July 16, 2024

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.

kevinohara80 avatar kevinohara80 commented on July 16, 2024

Same. Bummer.

from node-unzip.

theartofme avatar theartofme commented on July 16, 2024

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.

kevinohara80 avatar kevinohara80 commented on July 16, 2024

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.

remram44 avatar remram44 commented on July 16, 2024

Bumping into this too.

from node-unzip.

mtharrison avatar mtharrison commented on July 16, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.