Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser platform support #81

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ A Cordova plugin to unzip files in Android and iOS.
cordova plugin add cordova-plugin-zip

## Usage

```javascript
zip.unzip(<source zip>, <destination dir>, <callback>, [<progressCallback>]);

```
Both source and destination arguments can be URLs obtained from the HTML File
interface or absolute paths to files on the device.

Expand All @@ -19,16 +19,39 @@ success, or -1 on failure.

The progressCallback argument is optional and will be executed whenever a new ZipEntry
has been extracted. E.g.:

```javascript
var progressCallback = function(progressEvent) {
$( "#progressbar" ).progressbar("value", Math.round((progressEvent.loaded / progressEvent.total) * 100));
};

```
The values `loaded` and `total` are the number of compressed bytes processed and total. Total is the
file size of the zip file.

## Example
```typescript
const downZipUrl: string = downZipFileEntry.toInternalURL();
const downUnzipDirectoryUrl: string = downUnzipDir.toInternalURL();
zip.unzip(
downZipUrl,
downUnzipDirectoryUrl,
(result: CordovaZipPluginUnzipResult, errorMessage: string) => {
if (result == CordovaZipPluginUnzipResult.Success) {
resolve();
} else {
this.log.error(errorMessage, 'an error occurred during unzip');
reject('an error occurred during unzip: ' + errorMessage);
}
},
event => onProgress(event.loaded, event.total));
```

## Release Notes

### 3.2.0
* Browser platform support
* Updated doc
* Pass error message to upper layer

### 3.1.0 (Feb 23, 2016)
* Updated SSZipArchive (ios lib) to 1.1

Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 38 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
{
"name": "cordova-plugin-zip",
"version": "3.1.0",
"description": "Unzips zip files",
"cordova": {
"id": "cordova-plugin-unzip",
"platforms": [
"android",
"ios"
]
},
"repository": {
"type": "git",
"url": "https://github.com/MobileChromeApps/cordova-plugin-zip.git"
},
"keywords": [
"ecosystem:cordova",
"cordova-android",
"cordova-ios"
],
"engines": [
{
"name": "cordova",
"version": ">=3.3.0"
"name": "cordova-plugin-zip",
"version": "3.2.0",
"description": "Unzips zip files",
"cordova": {
"id": "cordova-plugin-unzip",
"platforms": [
"android",
"ios",
"browser"
]
},
"repository": {
"type": "git",
"url": "https://github.com/MobileChromeApps/cordova-plugin-zip.git"
},
"keywords": [
"cordova",
"zip",
"unzip",
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"cordova-browser"
],
"engines": [
{
"name": "cordova",
"version": ">=3.3.0"
}
],
"author": "",
"license": "BSD",
"bugs": {
"url": "https://github.com/MobileChromeApps/zip/issues"
},
"homepage": "https://github.com/MobileChromeApps/zip",
"devDependencies": {
"typescript": "3.9.5"
}
],
"author": "",
"license": "BSD",
"bugs": {
"url": "https://github.com/MobileChromeApps/zip/issues"
},
"homepage": "https://github.com/MobileChromeApps/zip"
}
13 changes: 12 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-zip"
version="3.1.0">
version="3.2.0">
<engines>
<engine name="cordova" version=">=3.3.0" />
</engines>
Expand All @@ -15,6 +15,17 @@
<clobbers target="zip" />
</js-module>

<platform name="browser">
<config-file target="config.xml" parent="/*">
<feature name="Zip">
<param name="browser-package" value="Zip" />
</feature>
</config-file>
<js-module name="ZipProxy" src="src/browser/ZipProxy.js">
<runs />
</js-module>
</platform>

<platform name="android">
<source-file src="src/android/Zip.java" target-dir="src/org/apache/cordova" />

Expand Down
Loading