Skip to content

Zip compression/decompression for the cordova/phonegap platform

License

Notifications You must be signed in to change notification settings

JianhuisHuang/cordova-plugin-zeep

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-zeep

Zip compression/decompression on the Apache Cordova / PhoneGap platform

Platforms

  • ios
  • android
  • windows

Add to project

cordova plugin add cordova-plugin-zeep

Remove from project

cordova plugin remove cordova-plugin-zeep

Compression (Zeep.zip or $cordovaZeep.zip)

from : [string] the path/url of the folder whose contents you want to compress
to     : [string] the path/url of the zip file that you want to produce

Decompression (Zeep.unzip or $cordovaZeep.unzip)

from : [string] the path/url of the zip file that you want to decompress
to     : [string] the path/url of the folder in which you want to deposit the contents of the zip file

Plain JS example

var source    = cordova.file.applicationDirectory,
    zip       = cordova.file.cacheDirectory + 'source.zip',
    extracted = cordova.file.cacheDirectory + 'extracted';

console.log('source    : ' + source   );
console.log('zip       : ' + zip      );
console.log('extracted : ' + extracted);

console.log('zipping ...');

Zeep.zip({
    from : source,
    to   : zip
}, function() {

    console.log('zip success!');
    console.log('unzipping ...');

    Zeep.unzip({
        from : zip,
        to   : extracted
    }, function() {
        console.log('unzip success!');
    }, function(e) {
        console.log('unzip error: ', e);
    });

}, function(e) {
    console.log('zip error: ', e);
});

Angular example

(+ other angular-based frameworks -> Ionic, Mobile Angular UI, LumX, MEAN, Angular Foundation, ...)

var app = angular.module('MyApp', ['ngCordova.plugins.zeep'])

...

app.controller('MyController', function($scope, $cordovaZeep) {
    
    var source    = cordova.file.applicationDirectory,
        zip       = cordova.file.cacheDirectory + 'source.zip',
        extracted = cordova.file.cacheDirectory + 'extracted';
    
    console.log('source    : ' + source   );
    console.log('zip       : ' + zip      );
    console.log('extracted : ' + extracted);
    
    console.log('zipping ...');
    
    $cordovaZeep.zip({
        from : source,
        to   : zip
    }).then(function() {
        
        console.log('zip success!');
        console.log('unzipping ...');
        
        $cordovaZeep.unzip({
            from : zip,
            to   : extracted
        }).then(function() {
            console.log('unzip success!');
        }, function(e) {
            console.log('unzip error: ', e);
        });
        
    }, function(e) {
        console.log('zip error: ', e);
    });
    
});

License

Apache 2.0

Buy me beer (maybe)

If you find this plugin useful, perhaps you can buy me a beer :)

About

Zip compression/decompression for the cordova/phonegap platform

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 77.3%
  • Objective-C 8.4%
  • C# 6.2%
  • C++ 4.4%
  • JavaScript 2.3%
  • Java 1.2%
  • Other 0.2%