adm-zip icon indicating copy to clipboard operation
adm-zip copied to clipboard

feature request | streaming implementation

Open jmonster opened this issue 11 years ago • 14 comments

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();
    }
  });

jmonster avatar Mar 02 '14 21:03 jmonster

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.

cthackers avatar Mar 12 '14 20:03 cthackers

nice.. also want that :)

ullmark avatar Mar 31 '14 11:03 ullmark

Me three!! This would be insanely helpful.

praxiswest avatar Jul 24 '14 22:07 praxiswest

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.

Anifacted avatar Aug 20 '14 10:08 Anifacted

@cthackers, have you had any movement on this?

meenie avatar Jan 12 '15 05:01 meenie

me too waiting on it

Kandy16 avatar Mar 31 '15 05:03 Kandy16

+1

newmanw avatar Apr 07 '15 20:04 newmanw

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.

Anifacted avatar Apr 08 '15 08:04 Anifacted

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

newmanw avatar Apr 08 '15 18:04 newmanw

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.

Anifacted avatar Apr 08 '15 18:04 Anifacted

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.

holographix avatar May 10 '15 17:05 holographix

streaming unzip is fundamentally flawed. streaming zip works fine.

andrewrk avatar May 15 '15 22:05 andrewrk

Currently, yazl supports creating archive from streams.

sntran avatar Dec 28 '21 18:12 sntran

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

aayusharyan avatar Jun 22 '24 11:06 aayusharyan