Skip to content

DocumentPicker

File and folder picker for importing and exporting

DocumentPicker provides system file picker UI for selecting and saving files.

Use DocumentPicker to:

Note

Not available in Widget

Examples

javascript
let paths = await DocumentPicker.open(["public.image"]);
if (paths) {
    console.log("Selected:", paths[0]);
}
javascript
await DocumentPicker.exportString("Hello World", "hello.txt");
javascript
let folder = await DocumentPicker.openFolder();

Methods

open

Open file picker with type filter

typescript
static open(types, callback): void
  • types - Optional array of UTType identifiers to filter (e.g., "public.image")
  • callback - Callback with error and array of selected paths

Example:

javascript
await DocumentPicker.open(["public.image"])

openFile

Open file picker for any file

typescript
static openFile(): void

Example:

javascript
let path = await DocumentPicker.openFile()

openFolder

Open folder picker

typescript
static openFolder(): void

Returns: Selected folder path or null if cancelled

Example:

javascript
let folder = await DocumentPicker.openFolder()

exportPath

Export a file at path

Opens save dialog to export an existing file.

typescript
static exportPath(path): void
  • path - Path to the file to export

Example:

javascript
await DocumentPicker.export("/path/to/file")

exportString

Export text content

typescript
static exportString(content, name): void
  • content - Text content to save
  • name - Optional filename

Example:

javascript
await DocumentPicker.exportString("content", "file.txt")

exportImage

Export an image

typescript
static exportImage(imageData, name): void
  • imageData - Image object with base64 data
  • name - Optional filename

Example:

javascript
await DocumentPicker.exportImage(image, "photo.png")

exportData

Export binary data

typescript
static exportData(data, name): void
  • data - Base64-encoded data string
  • name - Optional filename

Example:

javascript
await DocumentPicker.exportData(base64Data, "file.dat")