easy-zip
v0.0.4
Published
Easy zip is extend from jszip,run in the nodejs.
Downloads
23,244
Readme
Easy zip is extend from jszip,and run in the nodejs.
Installation
$ npm install easy-zip
Examples
var path = require('path'),
fs = require('fs'),
async = require('async'),
easyzip = require('./easyzip');
var zip = new easyzip.EasyZip();
//add text
zip.file('hello.txt','Hello World!');
zip.writeToFile('text.zip');//write zip data to disk
//add folder
var zip2 = new easyzip.EasyZip();
var jsFolder = zip2.folder('js');
jsFolder.file('hello.js','alert("hello world")');
zip2.writeToFile('folder.zip');
//add file
var zip3 = new easyzip.EasyZip();
zip3.addFile('main.js','easyzip.js',function(){
zip3.writeToFile('file.zip');
});
//batch add files
var files = [
{source : 'easyzip.js',target:'easyzip.js'},
{target : 'img'},//if source is null,means make a folder
{source : 'jszip.js',target:'lib/tmp.js'}
];
var zip4 = new easyzip.EasyZip();
zip4.batchAdd(files,function(){
zip4.writeToFile('batchadd.zip');
});
//zip a folder
var zip5 = new easyzip.EasyZip();
zip5.zipFolder('node_modules',function(){
zip5.writeToFile('folder.zip');
});
//write data to http.Response
//zip.writeToResponse(response,'attachment.zip');
//write to file sync
//zip.writeToFileSycn(filePath);
License
BSD