feat(file-chooser): add plugin (#4396)

This commit is contained in:
Alex Ryltsov 2022-11-04 22:45:27 +02:00 committed by GitHub
parent d2e92f5589
commit 97f566170e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,47 @@
/* eslint-disable jsdoc/require-returns-check */
/* eslint-disable jsdoc/check-tag-names */
import { Injectable } from '@angular/core';
import { Plugin, Cordova, AwesomeCordovaNativePlugin } from '@awesome-cordova-plugins/core';
/**
* @name FileChooser Plugin
* @description
* Cordova FileChooser Plugin
* @usage
* ```typescript
* import { FileChooser } from '@awesome-cordova-plugins/file-chooser/ngx';
*
*
* constructor(private fileChooser: FileChooser) { }
*
* ...
*
*
* this.fileChooser.open()
* .then(() => console.log('Success'))
* .catch((error: any) => console.error(error));
*
* ```
*/
@Plugin({
pluginName: 'FileChooser',
plugin: 'cordova-plugin-filechooser',
pluginRef: 'fileChooser',
repo: 'https://github.com/ihadeed/cordova-filechooser',
platforms: ['Android'],
})
@Injectable()
export class FileChooser extends AwesomeCordovaNativePlugin {
/**
* Launches a chooser dialog. The filter param allows filtering a the mime type
* { "mime": "application/pdf" }
*
* @param {string} [filter] Filter allowing filter by a mime type (text/plain, image/png, image/jpeg, audio/wav etc.)
* @returns {Promise<string>} URI of the selected file
*/
@Cordova()
open(filter?: string): Promise<string> {
return;
}
}