• We Code
  • We Design
  • We Develope
  • We Write
  • We Share


Thursday, May 29, 2014

PhoneGap / Cordova Unzip Plugin for android

While developing A phoneGap application i faced a problem in unzipping a folder. I downloaded a folder in zip from server using FileTransfer API.
I searched a lot for UnZIP plugin of phone gap but did not find any one the net . Than i started writing a fresh cordova plugin for unzipping

There is few prerequisite before using this plugin
Node.js and Cordova CLI or PhoneGap's CLI

Installation : 1 . Open Your terminal and go to your project directory
2 . Enter this command
phonegap  plugin add https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin.git
or If you using cordova
cordova  plugin add https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin.git
or you can download the plugin from Git repo Manually


3 .I Assume you downloaded the plugin manually from git repo

Copy the com folder inside the src folder under your android project

4 .Copy ExtractZipFile.js file inside your www folder and make its reference in index.html

5 . Open res/xml/config.xml file from your project and paste the line
   <feature name="ExtractZipFile">
                        <param name="android-package" value="com.phonegap.plugin.ExtractZipFile.ExtractZipFilePlugin"/>

 <plugin name="ExtractZipFile" value="com.phonegap.plugin.ExtractZipFile.ExtractZipFilePlugin" />

or Usage :
function extractOK(status)

function extractError(error)
    console.log("extractError "+error);

function extractFile(zipfile)
    console.log("Extracting "+ zipfile);
    extractZipFile.unzip(zipfile, extractOK, extractError);

Get the file reference and pass as parameter in function extractFile(zipfile) . And you are done with extractFile

Git Repo Link : https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin


Post a Comment