mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-03-17 09:01:07 +08:00
feat(zip): add plugin (#4238)
* added cordova-plugin-zip * Update index.ts Co-authored-by: Daniel Sogl <daniel@sogls.de>
This commit is contained in:
parent
64d2c55880
commit
0a31a374b1
43
src/@awesome-cordova-plugins/plugins/zip/index.ts
Normal file
43
src/@awesome-cordova-plugins/plugins/zip/index.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-plugins/core';
|
||||||
|
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Zip
|
||||||
|
* @description
|
||||||
|
* A Cordova plugin to unzip files in Android and iOS.
|
||||||
|
* @usage
|
||||||
|
* ```typescript
|
||||||
|
* import { Zip } from '@awesome-cordova-plugins/zip/nx'
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
* const result = await Zip.unzip('path/to/source.zip', 'path/to/dest', (progress) =>
|
||||||
|
* console.log('Unzipping, ' + Math.round((progress.loaded / progress.total) * 100) + '%')
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* if(result === 0) console.log('SUCCESS');
|
||||||
|
* if(result === -1) console.log('FAILED');
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
@Plugin({
|
||||||
|
pluginName: 'Zip',
|
||||||
|
plugin: 'cordova-plugin-zip',
|
||||||
|
pluginRef: 'zip',
|
||||||
|
repo: 'https://github.com/MobileChromeApps/cordova-plugin-zip',
|
||||||
|
platforms: ['Android', 'iOS'],
|
||||||
|
})
|
||||||
|
@Injectable()
|
||||||
|
export class Zip extends AwesomeCordovaNativePlugin {
|
||||||
|
/**
|
||||||
|
* Extracts files from a ZIP archive
|
||||||
|
* @param {string} sourceZip Source ZIP file
|
||||||
|
* @param {string} destFolder Destination folder
|
||||||
|
* @param {Function} onProgress 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
|
||||||
|
*/
|
||||||
|
@Cordova()
|
||||||
|
unzip(sourceZip: string, destFolder: string, onProgress?: Function): Promise<number> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user