https://github.com/eternalsayed/cordova-plugin-eszip
Cordova plugin for hybrid applications, such as those made with Ionic framework, to zip files and folders into a single zip file.
https://github.com/eternalsayed/cordova-plugin-eszip
archive cordova-plugin file folders hybrid-application ionic-framework zip
Last synced: 4 days ago
JSON representation
Cordova plugin for hybrid applications, such as those made with Ionic framework, to zip files and folders into a single zip file.
- Host: GitHub
- URL: https://github.com/eternalsayed/cordova-plugin-eszip
- Owner: eternalsayed
- Created: 2017-01-23T19:21:37.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-05T14:32:57.000Z (over 8 years ago)
- Last Synced: 2025-05-18T03:18:24.968Z (30 days ago)
- Topics: archive, cordova-plugin, file, folders, hybrid-application, ionic-framework, zip
- Language: Java
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cordova-plugin-eszip
Cordova plugin to provide zip functionality on hybrid applications, such as on those made with Ionic framework. The Java code is mostly borrowed from StackOverflow and so, I've done preprocessing in Javascript. Change it as it may suit you.# Why was this plugin needed?
The official cordova plugin for zipping failed for me, resulting in `bad zip`. I tried to debug it but couldn't so I thought why not make a simpler one which gaurantees solution.# Getting started
Install the plugin by using following command:
cordova plugin add cordova-plugin-eszip
Thereafter, the global object `ESzip` will be available in your app. Please note that this will not run on browsers so please test on actual devices/simulators only.# How to zip a folder?
* `ESzip` exposes function `zipFolder`, using which you can zip your source folder into destination zip file. Please note that `source` and `destination` are meant to be absolute paths, wherein `source` has to be an existing directory/file.
* `zipFolder` requires 4 parameters, namely: `source`, `destination`, `successCallback`, and `errorCallback`. `source` and `destination` have to be absolute file URLs.# Example
angular.module('starter.services',[])
.factory('$zip', function($q)
{
return {
zip: function(src, dest)
{
var deferred = $q.defer();
ESzip.zipFolder(src, dest, function(result)
{
if(result && result.success)//just to be sure
deferred.resolve(result);
else
deferred.reject(result);
},
function(err){
console.error(err);
deferred.reject(err);
})
return deferred.promise;
}
};
});