Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Zip

Improve this doc

A Cordova plugin to unzip files in Android and iOS.

Repo: https://github.com/MobileChromeApps/cordova-plugin-zip

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add cordova-plugin-zip
    $ npm install --save @ionic-native/zip@4
    
  2. Add this plugin to your app's module

Supported platforms

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

API

Native

General