Archiver v1.3.0
![Build status](https://ci.appveyor.com/api/projects/status/38kqu3yp159nodxe/branch/master?svg=true)
a streaming interface for archive generation
Visit the API documentation for a list of all methods available.
Install
npm install archiver --save
Quick Start
var fs = require('fs');
var archiver = require('archiver');
var output = fs.createWriteStream(__dirname + '/example.zip');
var archive = archiver('zip', {
store: true
});
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('archiver has been finalized and the output file descriptor has closed.');
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
var file1 = __dirname + '/file1.txt';
archive.append(fs.createReadStream(file1), { name: 'file1.txt' });
archive.append('string cheese!', { name: 'file2.txt' });
var buffer3 = new Buffer('buff it!');
archive.append(buffer3, { name: 'file3.txt' });
archive.file('file1.txt', { name: 'file4.txt' });
archive.directory('subdir/');
archive.glob('subdir/*.txt');
archive.finalize();
Formats
Archiver ships with out of the box support for TAR and ZIP archives.
You can register additional formats with registerFormat
.
Formats will be changing in the next few releases to implement a middleware approach.