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.gitor If you using cordova
cordova plugin add https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin.gitor you can download the plugin from Git repo Manually
https://github.com/ashishanautiyal/Unzip-PhoneGap--Plugin.git
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"/>
</feature>
or
<plugin name="ExtractZipFile" value="com.phonegap.plugin.ExtractZipFile.ExtractZipFilePlugin" />
function extractOK(status)
{
console.log("extractOK");
}
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






0 comments:
Post a Comment
...