# chooseFile

## Description

Selects an image or file from the device’s storage.

## Input / Parameter

| Name     | Description                              | Input Type | Default | Options             | Required |
| -------- | ---------------------------------------- | ---------- | ------- | ------------------- | -------- |
| type     | Type of file to choose.                  | Text       | -       | Image, Other\_Files | Yes      |
| multiple | Whether to select multiple files or not. | Boolean    | false   | true, false         | No       |

## Output

| Description                        | Output Type |
| ---------------------------------- | ----------- |
| Returns the formatted information. | Object      |

## Callback

### callback

The functions to be executed if file is chosen successfully.

| Description                          | Output Type |
| ------------------------------------ | ----------- |
| The information of the chosen files. | Object      |

Object format.

```
    {
        "extra": undefined,
        "input": [
            {
            "fileCopyUri": null,
            "name": "text.txt",
            "size": 4,
            "type": "text/plain",
            "uri": "file:///data/user/0/com.firstproject/cache/text.txt"
            }
        ]
    }
```

### errorCallback

The functions to be executed if the file is not chosen.

| Description        | Output Type |
| ------------------ | ----------- |
| The error message. | Text        |

## Example

In this example, we will use the `Device.chooseFile` function to get some files data and show it on the console.

### Step

1. Call the function `Device.chooseFile` inside the eventflow, and for it's `type` param select value `Image` and for it's `multiple` param select value `true`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-2bbbeab31768f6b1ce76b96d9311eecab53160df%2FchooseFile-step-1.png?alt=media)
2. Call the function `Log.write` inside the `Device.chooseFile` function callback, and for it's `value` param change the param type to `input`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-cd17fb16960f50e4b1440d7b6fd2752abbbf5b2a%2FchooseFile-step-2.png?alt=media)

### Result

1. Trigger the event.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-6252bd213f651ddc7d9bec314cf32779449e5a7d%2FchooseFile-result-1.png?alt=media)
2. Select the images.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-6fd4c5483b246b2c6dae855c95d0e22c0b7d56fe%2FchooseFile-result-2.png?alt=media)
3. Check the console.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-48377f9f922cdc7e401989622b51e7589a7688e3%2FchooseFile-result-3.png?alt=media)
