Skip to content

Instantly share code, notes, and snippets.



Last active Jul 7, 2020
What would you like to do?
npm install archiver;
var archiver = require('archiver'),
archive = archiver('zip'),
fs = require('fs');
var output = fs.createWriteStream(__dirname + '/');
var getStream = function(fileName){
return fs.readFileSync(fileName);
//these are the files, want to put into zip archive
var fileNames = ['', '', ''];
for(i=0; i<fileNames.length; i++){
var path = __dirname + '/'+fileNames[i];
archive.append(getStream(path), { name: fileNames[i]});
archive.finalize(function(err, bytes) {
if (err) {
throw err;
console.log(bytes + ' total bytes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.