Code Monkey home page Code Monkey logo

cordova-plugin-zeep's Introduction

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 a beer (maybe)

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

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.