Skip to content

DocumentPicker

Presents a document picker.

Use this to present a picker that allows opening a document from Files app or exporting a document to Files app. When opening a document, the picker will prompt you to select one or more documents after which you will get the path for the documents. Use the FileManager to read the content of these files. When exporting a document, the picker will ask you to select a destination to store the document.

+open

Opens a document.

static open(types: [string]): Promise<[string]>

Presents a document picker for opening a document from the Files app. It is up to the user to specify which types of files can be opened. Types are specified as UTIs, e.g. "public.plain-text" or "public.image". If you want to open a file of any file type, see the openFile function and if you want to open a folder, see the openFolder function.

When fulfilled the returned promise will provide the paths for the selected documents. Use an instance of FileManager to read the contents of the files.

Parameters

types
[string]
Types of files to select. Specified using UTIs. Defaults to all files.

Return value

Promise<[string]>
Promise that provides paths for the selected documents when fulfilled.


+openFile

Opens a file of any file type.

static openFile(): Promise<string>

Presents a document picker for opening a file from the Files app. The document picker will allow the selection of any file.

When fulfilled the returned promise will provide the paths for the selected files.

Return value

Promise
Promise that provides paths for the selected files when fulfilled.


+openFolder

Opens a folder.

static openFolder(): Promise<string>

Presents a document picker for opening a folder from the Files app.

When fulfilled the returned promise will provide the paths for the selected files.

Return value

Promise
Promise that provides paths for the selected folders when fulfilled.


+export

Exports a file to a document.

static export(path: string): Promise<[string]>

Exports the file to a document with. A picker prompting for a destination to export the document to is presented.

Parameters

path
string
Path of the file to export.

Return value

Promise<[string]>
Promise that provides paths for the selected file destination when fulfilled.


+exportString

Exports a string to a document.

static exportString(content: string, name: string): Promise<[string]>

Exports a string to a new file. The name of the file can optionally be specified. A picker prompting for a destination to export the document to is presented.

Parameters

content
string
Content of the document to export.

name
string
Optional name of the document to export.

Return value

Promise<[string]>
Promise that provides the path of the selected destination when fulfilled.


+exportImage

Exports an image.

static exportImage(image: Image, name: string): Promise<[string]>

Exports an image to a new file. The name of the file can optionally be specified. A picker prompting for a destination to export the document to is presented.

Parameters

image
Image
Image to export.

name
string
Optional name of the image to export.

Return value

Promise<[string]>
Promise that provides the path of the selected destination when fulfilled.


+exportData

Exports data.

static exportData(data: Data, name: string): Promise<[string]>

Exports data to a new file. The name of the file can optionally be specified. A picker prompting for a destination to export the document to is presented.

Parameters

data
Data
Data to export.

name
string
Optional name of the image to export.

Return value

Promise<[string]>
Promise that provides the path of the selected destination when fulfilled.