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 picker that promps for opening a document from the Files app. 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 files 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.