Skip to content
a streaming zip archive generator
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test fix Buffer usage for tests. Aug 10, 2018
.gitignore init. Jan 6, 2014
.travis.yml stop testing node 4 Aug 22, 2018
CHANGELOG.md bump for release. Aug 22, 2018
CONTRIBUTING.md init. Jan 6, 2014
LICENSE conform to spdx license standard. May 20, 2015
README.md
appveyor.yml stop testing node 4 Aug 22, 2018
deploy-docs.sh update jsdoc and related deploy script. Aug 23, 2018
index.js Fix forceLocalTime flag usage Jun 1, 2018
jsdoc.json doc adjustments. Aug 27, 2016
package-lock.json
package.json update jsdoc and related deploy script. Aug 23, 2018

README.md

ZipStream Build Status Build status

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.

Install

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.

Usage

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 = new packer(); // OR new packer(options)

archive.on('error', function(err) {
  throw err;
});

// pipe archive where you want it (ie fs, http, etc)
// listen to the destination's end, close, or finish event

archive.entry('string contents', { name: 'string.txt' }, function(err, entry) {
  if (err) throw err;
  archive.entry(null, { name: 'directory/' }, function(err, entry) {
    if (err) throw err;
    archive.finish();
  });
});

Credits

Concept inspired by Antoine van Wel's zipstream module, which is no longer being updated.

You can’t perform that action at this time.