You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30-11Lines changed: 30 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,22 +23,27 @@ If you are using RN >= 0.60, only run `pod install` from the ios directory. Then
23
23
24
24
#### RN < 0.60 / Manual Instructions
25
25
26
-
See [this](install-old.md)
26
+
See [this](./install-old.md)
27
27
28
28
## API
29
29
30
-
### `DocumentPicker.pick(opts)` and `DocumentPicker.pickMultiple(opts)`
30
+
####`DocumentPicker.pick(options)` and `DocumentPicker.pickMultiple(options)`
31
31
32
32
Use `pick` or `pickMultiple` to open a document picker for the user to select file(s). Both methods return a Promise. `pick` will only allow a single selection and the Promise will resolve to that single result. `pickMultiple` will allow multiple selection and the Promise returned will always resolve to an array of results.
33
33
34
-
**Options:**
34
+
### Options
35
35
36
-
-**`type`**:`string|Array<string>`: The type or types of documents to allow selection of. May be an array of types as single type string.
36
+
##### `type`:`string|Array<string>`:
37
+
38
+
The type or types of documents to allow selection of. May be an array of types as single type string.
37
39
- On Android these are MIME types such as `text/plain` or partial MIME types such as `image/*`.
38
40
- On iOS these must be Apple "[Uniform Type Identifiers](https://developer.apple.com/library/content/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html)"
39
41
- If `type` is omitted it will be treated as `*/*` or `public.content`.
40
42
- Multiple type strings are not supported on Android before KitKat (API level 19), Jellybean will fall back to `*/*` if you provide an array with more than one value.
41
-
-**[UWP only]`readContent`**: Boolean which defaults to `false`. If `readContent` is set to true the content of the picked file/files will be read and supplied in the result object.
43
+
44
+
##### `readContent`:
45
+
46
+
Boolean which defaults to `false`. If `readContent` is set to true the content of the picked file/files will be read and supplied in the result object.
42
47
43
48
- Be aware that this can introduce a huge performance hit in case of big files. (The files are read completely and into the memory and encoded to base64 afterwards to add them to the result object)
44
49
- However reading the file directly from within the Thread which managed the picker can be necessary on Windows: Windows Apps can only read the Downloads folder and their own app folder by default and If a file is outside of these locations it cannot be acessed directly. However if the user picks the file through a file picker permissions to that file are granted implicitly.
@@ -53,15 +58,29 @@ Use `pick` or `pickMultiple` to open a document picker for the user to select fi
53
58
54
59
- You can use `react-native-fs` on Android and IOS to read the picked file.
55
60
56
-
**Result:**
61
+
### Result
57
62
58
63
The object a `pick` Promise resolves to or the objects in the array a `pickMultiple` Promise resolves to will contain the following keys.
59
64
60
-
- **`uri`**: The URI representing the document picked by the user. _On iOS this will be a `file://` URI for a temporary file in your app's container. On Android this will be a `content://` URI for a document provided by a DocumentProvider that must be accessed with a ContentResolver._
61
-
- **`type`**: The MIME type of the file. _On Android some DocumentProviders may not provide MIME types for their documents. On iOS this MIME type is based on the best MIME type for the file extension according to Apple's internal "Uniform Type Identifiers" database._
62
-
- **`name`**: The display name of the file. _This is normally the filename of the file, but Android does not guarantee that this will be a filename from all DocumentProviders._
63
-
- **`size`**: The file size of the document. _On Android some DocumentProviders may not provide this information for a document._
64
-
- **[UWP only] `content`**: The base64 encoded content of the picked file if the option `readContent` was set to `true`.
65
+
##### `uri`:
66
+
67
+
The URI representing the document picked by the user. _On iOS this will be a `file://` URI for a temporary file in your app's container. On Android this will be a `content://` URI for a document provided by a DocumentProvider that must be accessed with a ContentResolver._
68
+
69
+
##### `type`:
70
+
71
+
The MIME type of the file. _On Android some DocumentProviders may not provide MIME types for their documents. On iOS this MIME type is based on the best MIME type for the file extension according to Apple's internal "Uniform Type Identifiers" database._
72
+
73
+
##### `name`:
74
+
75
+
The display name of the file. _This is normally the filename of the file, but Android does not guarantee that this will be a filename from all DocumentProviders._
76
+
77
+
##### `size`:
78
+
79
+
The file size of the document. _On Android some DocumentProviders may not provide this information for a document._
80
+
81
+
##### [UWP only] `content`:
82
+
83
+
The base64 encoded content of the picked file if the option `readContent` was set to `true`.
0 commit comments