Zip
A Cordova plugin to unzip files in Android and iOS.
Repo: https://github.com/MobileChromeApps/cordova-plugin-zip
Installation
- Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-zip $ npm install --save @ionic-native/zip@4
- Add this plugin to your app's module
Supported platforms
- Android
- iOS
Usage
import { Zip } from '@ionic-native/zip';
constructor(private zip: Zip) { }
...
this.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');
});
Instance Members
unzip(sourceZip, destUrl, onProgress)
Extracts files from a ZIP archive
Param | Type | Details |
---|---|---|
sourceZip |
string
|
Source ZIP file |
destUrl |
string
|
Destination folder |
onProgress |
Function
|
optional callback to be called on progress update |
Returns: Promise<number>
returns a promise that resolves with a number. 0 is success, -1 is error