Products · Dash API
Media
Let the person take or choose a photo, choose a file from their phone, or scan a QR code.
dash.media.pickPhoto
dash.media.pickPhoto(options: PickPhotoOptions, callOptions?: CallOptions): DashRequest<DotFile>Lets the person choose a photo or take one. Resolves with it as a JPEG of at most 2048 pixels on its longest side, without its location or other details. Rejects with cancelled if they close the picker, and with unsupported on a device without a camera. Save it with dash.storage.file.save to keep it after the dot closes.
Permission in dot.json: camera to take a photo, or photoLibrary to choose one.
Types: PickPhotoOptions, DotFile
dash.media.pickFile
dash.media.pickFile(options?: PickFileOptions, callOptions?: CallOptions): DashRequest<DotFile>Lets the person choose a file from their phone, of at most 25 MB. Rejects with cancelled if they close the picker, and with invalid for a larger file. Like a download, it lasts until the dot closes unless you save it with dash.storage.file.save.
Permission in dot.json: files.
Types: PickFileOptions, DotFile
dash.media.scanCode
dash.media.scanCode(callOptions?: CallOptions): DashRequest<ScannedCode>Opens Dash's scanner until it reads a QR code. Rejects with cancelled if the person closes it, and with unsupported where Dash has no scanner.
Permission in dot.json: camera.
Types: ScannedCode
Types
PhotoSource
type PhotoSource = 'library' | 'camera';PickPhotoOptions
| Field | Type | What it is |
|---|---|---|
source | PhotoSource | library needs the photoLibrary permission, and camera the camera permission. |
PickFileOptions
| Field | Type | What it is |
|---|---|---|
types (optional) | string[] | Content types the person may choose, such as 'application/pdf' or 'image/*'. Any file without them. |
CodeFormat
The kind of code that was scanned. Only QR codes for now.
type CodeFormat = 'qr';ScannedCode
| Field | Type | What it is |
|---|---|---|
text | string | What the code holds, as text. |
format | CodeFormat |