Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"singleQuote": true
}
91 changes: 40 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,50 @@
# Chooser

## Overview
### Overview

File chooser plugin for Cordova.
This plugin is an forked version of cordova plugin chooser that provides multiple file selection functionality and removes base64 functionality as we can use ionic native file plugin to get file directly

Install with Cordova CLI:
### Installing

$ 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;
}>

## Example Usage
```sh
cordova plugin add cordova-plugin-simple-file-chooser
```

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

- Android
- iOS

### API

```js
/**
* Displays native prompt for user to select one or more files.
*
* @param accept Optional MIME type filter (e.g. 'image/gif,video/*').
*
* @returns Promise containing selected files' information,
* MIME type, display name, and original URI.
*
* If user cancels, promise will be resolved as undefined.
* If error occurs, promise will be rejected.
*/
chooser.getFiles(accept?: string) : Promise<undefined|{
mediaType: string;
name: string;
uri: string;
}>
```

### Example Usage

## Platform-Specific Notes
```js
(async () => {
const file = await chooser.getFile();
console.log(file);
})();
```

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

```
<platform name="android">
<edit-config
file="app/src/main/AndroidManifest.xml"
mode="merge"
target="/manifest/application"
>
<application android:largeHeap="true" />
</edit-config>
</platform>
```
If calling in typescript don't use types instead use direct javascript by `declare var chooser` on your ts file.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"name": "cordova-plugin-chooser",
"version": "1.2.5",
"description": "Cordova file chooser plugin",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/cyph/cordova-plugin-chooser.git"
},
"keywords": [
"file",
"chooser",
"picker",
"file-chooser",
"android",
"ios"
],
"author": "Cyph, Inc. <[email protected]> (https://github.com/cyph)",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/cyph/cordova-plugin-chooser/issues"
},
"cordova": {
"id": "cordova-plugin-chooser",
"platforms": [
"android",
"ios"
]
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
"name": "cordova-plugin-simple-file-chooser",
"version": "3.0.2",
"description": "Cordova file chooser plugin",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/hc-oss/cordova-plugin-simple-file-chooser.git"
},
"keywords": [
"file",
"chooser",
"picker",
"file-chooser",
"android",
"ios"
],
"author": "Cyph, Inc. <[email protected]> (https://github.com/cyph)",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/hc-oss/cordova-plugin-simple-file-chooser/issues"
},
"cordova": {
"id": "cordova-plugin-simple-file-chooser",
"platforms": [
"android",
"ios"
]
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
8 changes: 4 additions & 4 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<plugin
xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-chooser"
version="1.2.5"
id="cordova-plugin-simple-file-chooser"
version="3.0.0"
>
<name>Chooser</name>
<author>Cyph, Inc.</author>
Expand All @@ -13,11 +13,11 @@
</js-module>

<platform name="android">
<source-file src="src/android/Chooser.java" target-dir="src/com/cyph/cordova" />
<source-file src="src/android/Chooser.java" target-dir="src/in/foobars/cordova" />

<config-file target="config.xml" parent="/*">
<feature name="Chooser">
<param name="android-package" value="com.cyph.cordova.Chooser" />
<param name="android-package" value="in.foobars.cordova.Chooser" />
</feature>
</config-file>
</platform>
Expand Down
Loading