- 18 May 2022
- 2 Minutes to read
-
DarkLight
-
PDF
Pick image from library
- Updated on 18 May 2022
- 2 Minutes to read
-
DarkLight
-
PDF
Picks an image from the device photo/image library.
By default, the app will request permissions to access the photo/image library, if they have not yet been granted. This behaviour can be overwritten by setting Request permission? to false. In this case, an error will be thrown if the permission has not been granted when the flow function is called.
The picked image is stored in a temporary directory with an autogenerated unique identifier for its filename. If you need to save the picked image in a persistent way, use the Move file flow function to move it to the user files directory.
If the user cancels the image picker dialog, the second output is triggered.
If there is an error, the third output is triggered.
Input arguments
Label | Key | Type | Required? | Default | Description |
---|---|---|---|---|---|
Request permission? | requestPermission |
Boolean | Yes | true | If true , the flow function will attempt to request permission to use the device photo/image library. |
Rationale dialog title | rationaleTitle |
String | No | Permission needed | Android-only. Title for a rationale dialog describing why the requested permission is needed. |
Rationale dialog message | rationaleMessage |
String | No | Permission to read device contact information is required. | Android-only. Message for a rationale dialog describing why the requested permission is needed. |
Rationale dialog confirm label | rationaleConfirmLabel |
String | No | Grant permission | Android-only. Text label for the confirm button in the rationale dialog. |
Rationale dialog cancel label | rationaleCancelLabel |
String | No | Reject permission | Android-only. Text label for the cancel button in the rationale dialog. |
Output arguments
Number of outputs: 3
Label | Key | Type | Description |
---|---|---|---|
Image file | imageFile
|
Object | Object representing the picked file. |
|
imageFile.path
|
String | Absolute local filesystem path representing the file location on the device, including the filename and extension. On web, this is created via the [`createObjectURL`](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL) method. |
|
imageFile.mimeType
|
String | MIME type of the file, if it could be determined. |
|
imageFile.name
|
String | Name of the file in the local filesystem, if applicable. Note that the filename and extension are included in the **Local path** property already. |
|
imageFile.size
|
Number | Size of the file, in bytes. |
|
imageFile.createdAt
|
String | Creation datetime of the file, if it can be determined. |
|
imageFile.modifiedAt
|
String | Datetime when the file was last modified, if it can be determined. |
Events
No events.
Errors
Label | Code | Description |
---|---|---|
Permission denied | permissionDenied |
Thrown if the user does not have sufficient permissions to open the photo/image library, or did not grant them when requested. |
Unkown error | unknown |
Thrown if an unknown error occured while opening the photo/image library and picking the image. |