Giter Site home page Giter Site logo

easy-zip's Introduction

Easy zip is extend from jszip,and run in the node.

Installation

$ npm install easy-zip

Examples

var EasyZip = require('easy-zip').EasyZip;

var zip = new EasyZip();
//add text
zip.file('hello.txt','Hello World!');
zip.writeToFile('text.zip');//write zip data to disk

//add folder
var zip2 = new EasyZip();
var jsFolder = zip2.folder('js');
jsFolder.file('hello.js','alert("hello world")');
zip2.writeToFile('folder.zip');

//add file
var zip3 = new 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();
zip4.batchAdd(files,function(){
	zip4.writeToFile('batchadd.zip');
});

//zip a folder
var zip5 = new EasyZip();
zip5.zipFolder('../easy-zip',function(){
	zip5.writeToFile('folderall.zip');
});

//zip a folder and change folder destination name
var zip6 = new EasyZip();
zip6.zipFolder('../easy-zip',function(){
    zip6.writeToFile('folderall.zip');
}, {rootFolder: 'easy-zip6'});

//write data to http.Response
//zip.writeToResponse(response,'attachment.zip');

//write to file sync
//zip.writeToFileSycn(filePath);

License

BSD

easy-zip's People

Contributors

deltaidea avatar joshbalfour avatar owenchong avatar sagarbhensjaliya avatar singuerinc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

easy-zip's Issues

Zipping a single file throws an error

    var zip = new EasyZip();
    zip.addFile('single-file.txt', function(){
        zip.writeToFile('file.zip');
    });

Trying to zip a single file using the above method throws a type error.

binding.open(pathModule._makeLong(path),
          ^
TypeError: path must be a string

Error when zip folder

Error:
Too many open files, open 'D:\Dev\AskFoodie\Web Service\Src\node_modules\request\node_modules\har-validator\lib\schemas\content.json' at Error (native)

file added in archive have 0 size

var zip5 = new EasyZip(); zip5.zipFolder('uploads',function(){ zip5.writeToFile('folderall.zip'); });

After add files into archive they have 0 size, but in folder they have normal size
What i did wrong

easy zip throws error when folder size is bigger than ~20mb

hi
i tried including easy zip in my node-mirror project.
https://npmjs.org/package/node-mirror

the main reason for me was because it seems to be the only zip implementation that handles folder reads async.
however when i try zipping a folder that is about 40mb big, easyzip wont finish and i get a error on command line

events.js:72
throw er; // Unhandled 'error' event

i am pretty sure you can reproduce it. just try to zip a folder that has lots of files and is about 40 mb in size.
thx
sol

WriteToFile Sycn typo is still there

WriteToFileSycn is still the way to access sync operation.

I see that you place a code that should fix the typo, but it did not, at least not in my case.
There is no check for typo fix in your test.js

How are errors handled?

How are errors handled in this module?

Normally there would be a callback which returns an error... or it would be a promise that resolves or rejects. How does it work in this module?

invalid compressed data to inflate

Hi,

I just tried to use easy-zip to zip a folder. My code is very simple:

var zip = new EasyZip();
zip.zipFolder(dir,function(){
    zip.writeToFile('test.zip, callback);
});

But when I try 'unzip -t test.zip' I get this:

Archive: test.zip
testing: icon.iconset/ OK
testing: manifest.json OK
testing: website.json OK
testing: icon.iconset/icon_16x16.png OK
testing: icon.iconset/icon_32x32.png
error: invalid compressed data to inflate
testing: icon.iconset/[email protected]
error: invalid compressed data to inflate
testing: icon.iconset/icon_128x128.png OK
testing: icon.iconset/[email protected] OK
testing: icon.iconset/[email protected]
error: invalid compressed data to inflate
At least one error was detected in test.zip

Any idea what the problem might be?

Unzip mess up with sub-folders

sridharrajs/folder-zip#1

Hey, I'm not sure why but when I unzip the file it create every sub-folder as parent ones. For example:

- file.zip
-- src
--- controllers
---- client
--- views

But when I unzip, I got

- src
-- src_controllers
-- src_controllers_client
-- src_views

Any idea?

Node deprecation Warning

When using :

zip.zipFolder('fileToZip', function () {
  zip.writeToFile('newPath.zip');
  console.log('done?');
});

Node gives the following warning:

[DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.

hex array ?

Hello

I saw that you use jszip but i could not find how to use hex array ? there is in jszip. can you help me. thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.