a streaming interface for archive generation
Visit the API documentation for a list of all methods available.
npm install archiver --save
// require modulesvar fs = ;var archiver = ;// create a file to stream archive data to.var output = fs;var archive =;// listen for all archive data to be writtenoutput;// good practice to catch warnings (ie stat failures and other non-blocking errors)archive;// good practice to catch this error explicitlyarchive;// pipe archive data to the filearchive;// append a file from streamvar file1 = __dirname + '/file1.txt';archive;// append a file from stringarchive;// append a file from buffervar buffer3 = Buffer;archive;// append a filearchive;// append files from a sub-directory and naming it `new-subdir` within the archivearchive;// append files from a sub-directory, putting its contents at the root of archivearchive;// append files from a glob patternarchive;// finalize the archive (ie we are done appending files but streams have to finish yet)archive;
Archiver ships with out of the box support for TAR and ZIP archives.
You can register additional formats with
Formats will be changing in the next few releases to implement a middleware approach.