# File Picker

{% embed url="<https://www.youtube.com/watch?v=nPQiBWPF4ZQ>" %}

Watch this on Youtube: <https://www.youtube.com/watch?v=nPQiBWPF4ZQ>

The File Picker action allows users to select a file from their device. This action supports filtering by file type, setting size limits, and optionally showing a toast after selection.

## Properties

| Property        | Type      | Required | Description                                                                              |
| --------------- | --------- | -------- | ---------------------------------------------------------------------------------------- |
| `File Type`     | Dropdown  | No       | Select allowed file type: `"audio"`, `"pdf"`, or `any` for any file type.                |
| `Size Limit`    | `number`  | No       | Maximum file size allowed in KB. Files exceeding this limit are filtered out.            |
| `Show Toast`    | `boolean` | No       | Whether to show a toast notification for files exceeding size limit. Defaults to `true`. |
| `File Variable` | Dropdown  | No       | Select variable where the selected file will be stored.                                  |

## Use Cases

* **Document Upload**: Allow users to upload PDFs, documents, or certificates
* **Audio Files**: Select music files, voice recordings, or podcasts
* **Form Attachments**: Attach files to forms, applications, or messages
* **Media Libraries**: Build collections of user-uploaded content
* **Data Import**: Allow users to import data files for processing

## Default Behavior

By default:

| Behavior              | Description                                                |
| --------------------- | ---------------------------------------------------------- |
| **File Types**        | All file types allowed if `File Type` not specified        |
| **Selection Mode**    | Single file selection                                      |
| **Size Limits**       | No size restrictions if `Size Limit` not specified         |
| **Toast Display**     | Shows size limit warnings unless `Show Toast` is false     |
| **File Storage**      | Selected file stored in specified `File Variable` variable |
| **User Cancellation** | Action completes without error if user cancels picker      |

## How to Use

<figure><img src="https://3626461507-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbhApDTL7kHrXte2TTtjs%2Fuploads%2Fgit-blob-9c6e38b646f98c9ef02bbaf8eb3a25cb863b2725%2Ffile_picker_action.png?alt=media" alt="Call External Method action configuration showing message name and payload fields"><figcaption><p>Call External Method action configuration in Digia Studio</p></figcaption></figure>

1. Attach the action to a widget event (button tap, icon press, etc.)
2. Select **File Picker** from the action list
3. Optionally specify `File Type` to restrict file types
4. Set `Size Limit` in KB to restrict file sizes
5. Specify `File Variable` variable to store selected file

## Implementation Details

The action uses the `file_picker` package to access device file systems. Selected files are converted to `AdaptedFile` objects containing file data, metadata, and size information.

Size limits are enforced in KB (converted to bytes internally). Files exceeding the limit are automatically filtered out, and users see toast notifications when `Show Toast` is enabled.

## Related Actions

* [Image Picker](https://docs.digia.tech/logic-and-interaction/actions/image-picker) - Select images and videos with camera/gallery options
* [Upload](https://docs.digia.tech/logic-and-interaction/actions/upload) - Upload selected files to a server
* [Set State](https://docs.digia.tech/logic-and-interaction/actions/set-state) - Update UI state with selected files

***
