Chooser
Overview
File chooser plugin for Cordova.
Install with Cordova CLI:
$ cordova plugin add cordova-plugin-chooser
Supported Platforms:
API
/**
* Displays native prompt for user to select a file.
*
* @param accept Optional MIME type filter (e.g. 'image/gif,video/*').
*
* @returns Promise containing selected file's binary data,
* MIME type, display name, and full URI.
* If user cancels, promise will be resolved as undefined.
* If error occurs, promise will be rejected.
*/
chooser.getFile(accept?: string) : Promise<undefined|{
data: Uint8Array;
mediaType: string;
name: string;
uri: string;
}>
Example Usage
(async () => {
const file = await chooser.getFile();
console.log(file ? file.name : 'canceled');
})();