Skip to content

Commit e09ad1e

Browse files
authored
docs: improve readme (#478)
* docs: improve readme * chore: prettify
1 parent 023b67e commit e09ad1e

File tree

3 files changed

+49
-15
lines changed

3 files changed

+49
-15
lines changed

README.md

+49-15
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,47 @@ A React Native wrapper for:
1010
- Android's `Intent.ACTION_GET_CONTENT`
1111
- Windows `Windows.Storage.Pickers`
1212

13+
<table>
14+
<tr><td><strong>iOS</strong></td><td><strong>Android</strong></td></tr>
15+
<tr>
16+
<td><p align="center"><img src="/docs/ios_screenshot.jpeg" height="500"></p></td>
17+
<td><p align="center"><img src="/docs/android_screenshot.jpg" height="500"></p></td>
18+
</tr>
19+
</table>
20+
1321
Requires RN >= 0.63, Android 5.0+ and iOS 11+
1422

23+
# Table of Contents
24+
25+
- [react-native-document-picker](#react-native-document-picker)
26+
- [Installation](#installation)
27+
- [RN &gt;= 0.63](#rn--063)
28+
- [API](#api)
29+
- [DocumentPicker.pickMultiple(options) / DocumentPicker.pickSingle(options) / DocumentPicker.pick(options)](#documentpickerpickmultipleoptions--documentpickerpicksingleoptions--documentpickerpickoptions)
30+
- [[Android and Windows only] DocumentPicker.pickDirectory()](#android-and-windows-only-documentpickerpickdirectory)
31+
- [DocumentPicker.pick(options) and DocumentPicker.pickMultiple(options)](#documentpickerpickoptions-and-documentpickerpickmultipleoptions)
32+
- [Options](#options)
33+
- [allowMultiSelection:boolean](#allowmultiselectionboolean)
34+
- [type:string|Array&lt;string&gt;](#typestringarraystring)
35+
- [[iOS only] presentationStyle:'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen'](#ios-only-presentationstylefullscreen--pagesheet--formsheet--overfullscreen)
36+
- [[iOS only] mode:"import" | "open"](#ios-only-modeimport--open)
37+
- [[iOS and Android only] copyTo:"cachesDirectory" | "documentDirectory"](#ios-and-android-only-copytocachesdirectory--documentdirectory)
38+
- [[Windows only] readContent:boolean](#windows-only-readcontentboolean)
39+
- [Result](#result)
40+
- [uri](#uri)
41+
- [fileCopyUri](#filecopyuri)
42+
- [type](#type)
43+
- [name](#name)
44+
- [size](#size)
45+
- [[Windows only] content](#windows-only-content)
46+
- [DocumentPicker.types.\*](#documentpickertypes)
47+
- [DocumentPicker.isCancel(err)](#documentpickeriscancelerr)
48+
- [DocumentPicker.isInProgress(err)](#documentpickerisinprogresserr)
49+
- [[iOS only] DocumentPicker.releaseSecureAccess(uris: Array&lt;string&gt;)](#ios-only-documentpickerreleasesecureaccessuris-arraystring)
50+
- [Example](#example)
51+
- [How to upload picked files?](#how-to-upload-picked-files)
52+
- [Help wanted: Improvements](#help-wanted-improvements)
53+
1554
### Installation
1655

1756
```bash
@@ -51,11 +90,11 @@ Open a system directory picker. Returns a promise that resolves to (`{ uri: stri
5190

5291
All of the options are optional
5392

54-
##### `allowMultiSelection`:`boolean`:
93+
##### `allowMultiSelection`:`boolean`
5594

5695
Whether or not selecting multiple files is allowed. For `pick`, this is `false` by default. `allowMultiSelection` is `false` for `pickSingle` and `true` for `pickMultiple` and cannot be overridden for those calls.
5796

58-
##### `type`:`string|Array<string>`:
97+
##### `type`:`string|Array<string>`
5998

6099
The type or types of documents to allow selection of. May be an array of types as single type string.
61100

@@ -67,11 +106,11 @@ The type or types of documents to allow selection of. May be an array of types a
67106

68107
Controls how the picker is presented, eg. on an iPad you may want to present it fullscreen. Defaults to `pageSheet`.
69108

70-
##### [iOS only] `mode`:`"import" | "open"`:
109+
##### [iOS only] `mode`:`"import" | "open"`
71110

72111
Defaults to `import`. If `mode` is set to `import` the document picker imports the file from outside to inside the sandbox, otherwise if `mode` is set to `open` the document picker opens the file right in place.
73112

74-
##### [iOS and Android only] `copyTo`:`"cachesDirectory" | "documentDirectory"`:
113+
##### [iOS and Android only] `copyTo`:`"cachesDirectory" | "documentDirectory"`
75114

76115
If specified, the picked file is copied to `NSCachesDirectory` / `NSDocumentDirectory` (iOS) or `getCacheDir` / `getFilesDir` (Android). The uri of the copy will be available in result's `fileCopyUri`. If copying the file fails (eg. due to lack of space), `fileCopyUri` will be the same as `uri`, and more details about the error will be available in `copyError` field in the result.
77116

@@ -98,27 +137,27 @@ Defaults to `false`. If `readContent` is set to true the content of the picked f
98137

99138
The `pick` Promise resolves to an array of objects with the following keys.
100139

101-
##### `uri`:
140+
##### `uri`
102141

103142
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 if `mode` is not specified or set at `import` otherwise it will be the original `file://` URI. On Android this will be a `content://` URI for a document provided by a DocumentProvider that must be accessed with a ContentResolver._
104143

105-
##### `fileCopyUri`:
144+
##### `fileCopyUri`
106145

107146
Same as `uri`, but has special meaning if `copyTo` option is specified.
108147

109-
##### `type`:
148+
##### `type`
110149

111150
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._
112151

113-
##### `name`:
152+
##### `name`
114153

115154
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._
116155

117-
##### `size`:
156+
##### `size`
118157

119158
The file size of the document. _On Android some DocumentProviders may not provide this information for a document._
120159

121-
##### [Windows only] `content`:
160+
##### [Windows only] `content`
122161

123162
The base64 encoded content of the picked file if the option `readContent` was set to `true`.
124163

@@ -203,18 +242,13 @@ try {
203242
}
204243
```
205244

206-
## Here is how it looks:
207-
208-
<img src="./docs/screenshot.jpeg" height="400">
209-
210245
## How to upload picked files?
211246

212247
Use blob support that is built into react native - [see comment](https://github.com/rnmods/react-native-document-picker/issues/70#issuecomment-384335402).
213248
If you need to track upload progress, use `XMLHttpRequest` [see here](https://gist.github.com/Tamal/9231005f0c62e1a3f23f60dc2f46ae35)
214249

215250
Alternatively, use [https://github.com/johanneslumpe/react-native-fs](https://github.com/johanneslumpe/react-native-fs)
216251

217-
218252
## Help wanted: Improvements
219253

220254
- Fix Xcode warning about constraints

docs/android_screenshot.jpg

101 KB
Loading
File renamed without changes.

0 commit comments

Comments
 (0)