Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: better docs around uti+mime #654

Merged
merged 1 commit into from
May 16, 2023
Merged
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
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