Skip to content

Commit

Permalink
feat(zip): add zip plugin (#430)
Browse files Browse the repository at this point in the history
closes #421
  • Loading branch information
ihadeed authored Aug 15, 2016
1 parent d4c6ea4 commit e34f94e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import {TwitterConnect} from './plugins/twitter-connect';
import {Vibration} from './plugins/vibration';
import {VideoPlayer} from './plugins/video-player';
import {WebIntent} from './plugins/webintent';
import {Zip} from './plugins/zip';
export * from './plugins/3dtouch';
export * from './plugins/background-geolocation';
export * from './plugins/backgroundmode';
Expand Down Expand Up @@ -166,7 +167,8 @@ export {
TouchID,
Transfer,
Vibration,
WebIntent
WebIntent,
Zip
}

export * from './plugins/plugin';
Expand Down Expand Up @@ -251,7 +253,8 @@ window['IonicNative'] = {
TwitterConnect: TwitterConnect,
VideoPlayer: VideoPlayer,
Vibration: Vibration,
WebIntent: WebIntent
WebIntent: WebIntent,
Zip: Zip
};

initAngular1(window['IonicNative']);
Expand Down
39 changes: 39 additions & 0 deletions src/plugins/zip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {Plugin, Cordova} from './plugin';

/**
* @name Zip
* @description
* A Cordova plugin to unzip files in Android and iOS.
*
* @usage
* ```
* import {Zip} from 'ionic-native';
*
* Zip.unzip('path/to/source.zip', 'path/to/dest', (progress) => console.log('Unzipping, ' + Math.round((progress.loaded / progress.total) * 100) + '%'))
* .then((result) => {
* if(result === 0) console.log('SUCCESS');
* if(result === -1) console.log('FAILED');
* });
*
* ```
*/
@Plugin({
plugin: 'cordova-plugin-zip',
pluginRef: 'zip',
repo: 'https://github.com/MobileChromeApps/cordova-plugin-zip',
})
export class Zip {
/**
* Extracts files from a ZIP archive
* @param sourceZip {string} Source ZIP file
* @param destUrl {string} Destination folder
* @param onProgress {Function} optional callback to be called on progress update
* @return {Promise<number>} returns a promise that resolves with a number. 0 is success, -1 is error
*/
@Cordova({
successIndex: 2,
errorIndex: 4
})
static unzip(sourceZip: string, destUrl: string, onProgress: Function): Promise<number> {return; }

}

0 comments on commit e34f94e

Please sign in to comment.