1.3.2 • Published 4 years ago

cordova-plugin-chooser v1.3.2

Weekly downloads
2,623
License
Apache-2.0
Repository
github
Last release
4 years ago

Chooser

Overview

File chooser plugin for Cordova.

Install with Cordova CLI:

$ cordova plugin add cordova-plugin-chooser

Supported Platforms:

  • Android

  • iOS

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 raw binary data,
 * base64-encoded data: URI, MIME type, display name, and original 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;
	dataURI: string;
	mediaType: string;
	name: string;
	uri: string;
}>

/**
 * 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 MIME type, display name,
 * and original URI.
 *
 * If user cancels, promise will be resolved as undefined.
 * If error occurs, promise will be rejected.
 */
chooser.getFileMetadata(accept?: string) : Promise<undefined|{
	mediaType: string;
	name: string;
	uri: string;
}>

Example Usage

(async () => {
	const file = await chooser.getFile();
	console.log(file ? file.name : 'canceled');
})();

Platform-Specific Notes

The following must be added to config.xml to prevent crashing when selecting large files on Android:

<platform name="android">
	<edit-config
		file="app/src/main/AndroidManifest.xml"
		mode="merge"
		target="/manifest/application"
	>
		<application android:largeHeap="true" />
	</edit-config>
</platform>

If it isn't present already, you'll also need the attribute xmlns:android="http://schemas.android.com/apk/res/android" added to your <widget> tag in order for that to build successfully.

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

5 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago