-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(file-chooser): add plugin (#4396)
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/@awesome-cordova-plugins/plugins/file-chooser/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |