a streaming zip archive generator.
zip-stream is a streaming zip archive generator based on the
ZipArchiveOutputStream prototype found in the compress-commons project.
It was originally created to be a successor to zipstream.
Visit the API documentation for a list of all methods available.
npm install zip-stream --save
You can also use
npm install https://github.com/archiverjs/node-zip-stream/archive/master.tar.gz to test upcoming versions.
This module is meant to be wrapped internally by other modules and therefore lacks any queue management. This means you have to wait until the previous entry has been fully consumed to add another. Nested callbacks should be used to add multiple entries. There are modules like async that ease the so called "callback hell".
If you want a module that handles entry queueing and much more, you should check out archiver which uses this module internally.
var packer = require'zip-stream';var archive = ; // OR new packer(options)archiveon'error'throw err;;// pipe archive where you want it (ie fs, http, etc)// listen to the destination's end, close, or finish eventarchiveentry'string contents' name: 'string.txt'if err throw err;archiveentrynull name: 'directory/'if err throw err;archivefinish;;;
Concept inspired by Antoine van Wel's zipstream module, which is no longer being updated.