Skip to content

Commit

Permalink
docs: better docs around uti+mime (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonovak authored May 16, 2023
1 parent b21978d commit 3f7e270
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ A React Native wrapper for:

Requires RN >= 0.69, Android 5.0+ and iOS 11+

New architecture is supported.

# Table of Contents

- [react-native-document-picker](#react-native-document-picker)
Expand Down Expand Up @@ -85,11 +83,12 @@ expo run:ios
expo run:android
```


#### RN >= 0.69

If you are using RN >= 0.69, only run `pod install` from the ios directory. Then rebuild your project. Older RN versions are not supported.

New architecture is supported with RN >= 71.

## API

#### `pickSingle(options)` / `pick(options)`
Expand All @@ -102,7 +101,6 @@ Use `pickSingle` or `pick` to open a document picker for the user to select file

- `pickSingle` is "sugar function" on top of `pick` and only allows a single selection returns `Promise<DocumentPickerResponse>`


#### `pickDirectory()`

Open a system directory picker. Returns a promise that resolves to (`{ uri: string }`) of the directory selected by user.
Expand All @@ -120,7 +118,7 @@ Whether selecting multiple files is allowed. For `pick`, this is `false` by defa
The type or types of documents to allow selection of. An array of strings or single string.

- On Android, these are MIME types such as `text/plain` or partial MIME types such as `image/*`. See [common MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types).
- On iOS, these must be Apple "[Uniform Type Identifiers](https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared_uniform_type_identifiers?language=objc)"
- On iOS, these must be Apple [Uniform Type Identifiers](https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared_uniform_type_identifiers?language=objc)
- If `type` is omitted it will be treated as `*/*` or `public.item`.

#### [iOS and Android only] `copyTo`:`"cachesDirectory" | "documentDirectory"`
Expand Down Expand Up @@ -194,6 +192,14 @@ The base64 encoded content of the picked file if the option `readContent` was se

`DocumentPicker.types.*` provides a few common types for use as `type` values, these types will use the correct format for each platform (MIME types on Android, UTIs on iOS).

If you need to provide your own file type filtering:

For Android, see [common MIME types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types).

For iOS [Uniform Type Identifiers](https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared_uniform_type_identifiers?language=objc).

Also, searching Google usually helps.

- `DocumentPicker.types.allFiles`: All document types, on Android this is `*/*`, on iOS is `public.item`
- `DocumentPicker.types.images`: All image types
- `DocumentPicker.types.plainText`: Plain text files
Expand Down

0 comments on commit 3f7e270

Please sign in to comment.