Skip to content

Commit 0a31a37

Browse files
feat(zip): add plugin (#4238)
* added cordova-plugin-zip * Update index.ts Co-authored-by: Daniel Sogl <[email protected]>
1 parent 64d2c55 commit 0a31a37

File tree

1 file changed

+43
-0
lines changed
  • src/@awesome-cordova-plugins/plugins/zip

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-plugins/core';
2+
3+
import { Injectable } from '@angular/core';
4+
5+
/**
6+
* @name Zip
7+
* @description
8+
* A Cordova plugin to unzip files in Android and iOS.
9+
* @usage
10+
* ```typescript
11+
* import { Zip } from '@awesome-cordova-plugins/zip/nx'
12+
* ...
13+
*
14+
* const result = await Zip.unzip('path/to/source.zip', 'path/to/dest', (progress) =>
15+
* console.log('Unzipping, ' + Math.round((progress.loaded / progress.total) * 100) + '%')
16+
* );
17+
*
18+
* if(result === 0) console.log('SUCCESS');
19+
* if(result === -1) console.log('FAILED');
20+
*
21+
* ```
22+
*/
23+
@Plugin({
24+
pluginName: 'Zip',
25+
plugin: 'cordova-plugin-zip',
26+
pluginRef: 'zip',
27+
repo: 'https://github.com/MobileChromeApps/cordova-plugin-zip',
28+
platforms: ['Android', 'iOS'],
29+
})
30+
@Injectable()
31+
export class Zip extends AwesomeCordovaNativePlugin {
32+
/**
33+
* Extracts files from a ZIP archive
34+
* @param {string} sourceZip Source ZIP file
35+
* @param {string} destFolder Destination folder
36+
* @param {Function} onProgress optional callback to be called on progress update
37+
* @returns {Promise<number>} returns a promise that resolves with a number. 0 is success, -1 is error
38+
*/
39+
@Cordova()
40+
unzip(sourceZip: string, destFolder: string, onProgress?: Function): Promise<number> {
41+
return;
42+
}
43+
}

0 commit comments

Comments
 (0)