From 97f566170efdc90f48a4f7b4aef292dccfb0165c Mon Sep 17 00:00:00 2001 From: Alex Ryltsov Date: Fri, 4 Nov 2022 22:45:27 +0200 Subject: [PATCH] feat(file-chooser): add plugin (#4396) --- .../plugins/file-chooser/index.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/@awesome-cordova-plugins/plugins/file-chooser/index.ts diff --git a/src/@awesome-cordova-plugins/plugins/file-chooser/index.ts b/src/@awesome-cordova-plugins/plugins/file-chooser/index.ts new file mode 100644 index 0000000000..84cf51b778 --- /dev/null +++ b/src/@awesome-cordova-plugins/plugins/file-chooser/index.ts @@ -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} URI of the selected file + */ + @Cordova() + open(filter?: string): Promise { + return; + } +}