# Media (/docs/products/dash-dots/reference/dash-api/media)

## `dash.media.pickPhoto`

```ts
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`](/docs/products/dash-dots/reference/dot-json): `camera` to take a photo, or `photoLibrary` to choose one.

Types: [`PickPhotoOptions`](/docs/products/dash-dots/reference/dash-api/media#pickphotooptions), [`DotFile`](/docs/products/dash-dots/reference/dash-api/files#dotfile)

## `dash.media.pickFile`

```ts
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`](/docs/products/dash-dots/reference/dot-json): `files`.

Types: [`PickFileOptions`](/docs/products/dash-dots/reference/dash-api/media#pickfileoptions), [`DotFile`](/docs/products/dash-dots/reference/dash-api/files#dotfile)

## `dash.media.scanCode`

```ts
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`](/docs/products/dash-dots/reference/dot-json): `camera`.

Types: [`ScannedCode`](/docs/products/dash-dots/reference/dash-api/media#scannedcode)

## Types

### `PhotoSource`

```ts
type PhotoSource = 'library' | 'camera';
```

### `PickPhotoOptions`

| Field    | Type                                                                           | What it is                                                                           |
| -------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ |
| `source` | [`PhotoSource`](/docs/products/dash-dots/reference/dash-api/media#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.

```ts
type CodeFormat = 'qr';
```

### `ScannedCode`

| Field    | Type                                                                         | What it is                    |
| -------- | ---------------------------------------------------------------------------- | ----------------------------- |
| `text`   | `string`                                                                     | What the code holds, as text. |
| `format` | [`CodeFormat`](/docs/products/dash-dots/reference/dash-api/media#codeformat) |                               |
