Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
→
expo install expo-document-picker
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
usesIcloudStorage
key to true
in your app.json file as specified here.iCloud.<your_bundle_identifier>
.expo build:ios -c
DocumentPicker
module requires the iCloud entitlement to work properly. If your app doesn't have it already, you can add it by opening the project in Xcode and following these steps:Capabilities
tabon
iCloud Documents
checkboximport * as DocumentPicker from 'expo-document-picker';
DocumentPickerOptions
)Display the system UI for choosing a document. By default, the chosen file is copied to the app's internal cache directory.
Notes for Web: The system UI can only be shown after user activation (e.g. aButton
press).
Therefore, calling getDocumentAsync
in componentDidMount
, for example, will not work as
intended. The cancel
event will not be returned in the browser due to platform restrictions and
inconsistencies across browsers.
On success returns a promise that fulfils with DocumentResult
object.
If the user cancelled the document picking, the promise resolves to { type: 'cancel' }
.
Name | Type | Description |
---|---|---|
copyToCacheDirectory (optional) | boolean | If true , the picked file is copied to FileSystem.CacheDirectory ,
which allows other Expo APIs to read the file immediately. This may impact performance for
large files, so you should consider setting this to false if you expect users to pick
particularly large files and your app does not need immediate read access.Default: `true`
|
multiple (optional) | boolean | Web Only. Allows multiple files to be selected from the system UI. Default: `false`
|
type (optional) | string | string[] | The MIME type(s) of the documents that are available
to be picked. Is also supports wildcards like 'image/*' to choose any image. To allow any type
of document you can use '*/*' .Default: `'*/*'`
|
Name | Type | Description |
---|---|---|
type | 'cancel' | - |
Name | Type | Description |
---|---|---|
file (optional) | File | - |
lastModified (optional) | number | - |
mimeType (optional) | string | Document MIME type. |
name | string | Document original name. |
output (optional) | FileList | null | - |
size (optional) | number | Document size in bytes. |
type | 'success' | - |
uri | string | An URI to the local document file. |