cthackers / adm-zip

A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk
MIT License
2.04k stars 376 forks source link

feature request | streaming implementation #84

Open jmonster opened 10 years ago

jmonster commented 10 years ago

I have a server that will be receiving up to 50MB files. I'd like to avoid buffering this request for obvious reasons :)

example API:

aReadableStream
  .pipe(admZip.parseStream)
  .on('entry', function (entry) {
    var fileName = entry.path;
    var type = entry.type; // 'Directory' or 'File'
    var size = entry.size;
    if (type == 'File' && fileName === 'target.png') {
      // capture the data for this one entry
      entry.pipe(fs.createWriteStream('path/to/target.png'));
    } else {
      entry.discard();
    }
  });
cthackers commented 10 years ago

It's on going. The new version will have readers and writers that can take any reader (string, buffer, file, socket) as input and you read from them the zipped/unzipped version. there is a new branch you can take a look at if you want. still some fixes to do and the initial api implementation.

ullmark commented 10 years ago

nice.. also want that :)

praxiswest commented 10 years ago

Me three!! This would be insanely helpful.

Anifacted commented 10 years ago

I would love to see streaming functionality in this library as well. I am afraid that having to load files into memory is keeping me from using the module as it is.

meenie commented 9 years ago

@cthackers, have you had any movement on this?

Kandy16 commented 9 years ago

me too waiting on it

newmanw commented 9 years ago

+1

Anifacted commented 9 years ago

For anyone looking for streamable zipping and unzipping, yazl and yauzl have my recommendations!

Yazl (Zipping): https://www.npmjs.com/package/yazl Yauzl (Unzipping): https://www.npmjs.com/package/yauzl

Very clean and stable API.

newmanw commented 9 years ago

To be fair, yauzl does not and will not supporting streaming: https://github.com/thejoshwolfe/yauzl/issues/12

Anifacted commented 9 years ago

Hmm. You're right. I didn't realize that, since the event based API lead my thoughts towards streams. From the author's comment, though, it seems that streaming in an unzipping library isn't such a good idea after all.

Thankfully, it also seems that yauzl is aware and efficient when it comes to buffering, so it may be our best choice in any case.

holographix commented 9 years ago

FWIW I stumbled upon this http://stackoverflow.com/questions/20107303/dynamically-create-and-stream-zip-to-client

Although it illustrate a solution that uses node-archiver (https://github.com/archiverjs/node-archiver), I hope that could help someone anyhow.

andrewrk commented 9 years ago

streaming unzip is fundamentally flawed. streaming zip works fine.

sntran commented 2 years ago

Currently, yazl supports creating archive from streams.

aayusharyan commented 4 months ago

It is a very niche usecase but when you need it, you need it.