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): voidtypes- 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(): voidExample:
javascript
let path = await DocumentPicker.openFile()openFolder
Open folder picker
typescript
static openFolder(): voidReturns: 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): voidpath- Path to the file to export
Example:
javascript
await DocumentPicker.export("/path/to/file")exportString
Export text content
typescript
static exportString(content, name): voidcontent- Text content to savename- Optional filename
Example:
javascript
await DocumentPicker.exportString("content", "file.txt")exportImage
Export an image
typescript
static exportImage(imageData, name): voidimageData- Image object with base64 dataname- Optional filename
Example:
javascript
await DocumentPicker.exportImage(image, "photo.png")exportData
Export binary data
typescript
static exportData(data, name): voiddata- Base64-encoded data stringname- Optional filename
Example:
javascript
await DocumentPicker.exportData(base64Data, "file.dat")