Getting Item Files
Data Format of the Files Column
The "Files" column is one of the item columns output by many monday actions/triggers. For example, when you use the "Get items" action, the "Files" field is one of the fields that is returned.
This field contains a list of files that are attached to the files column for an item. The file data is formatted in JSON (JavaScript Object Notation) format.
Here's an example:
{
"files":[
{
"name":"waterfall.jpeg",
"public_url":"https://files-monday-com.s3.amazonaws.com/315151/resources/124414124124/download%20%283%29.jpeg?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA4MPVJMFXILAOBJXD%2F20240315%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240315T204108Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=5ffcce0c07c81907a46a70d7bc060bebacc739c70156e6e0decd3fca82e19ea7",
"url": "https://example.monday.com/protected_static/315151/resources/234234234/waterfall.jpeg",
"isImage":"true"
},
{
"name":"sunset_lake.jpeg",
"public_url":"https://files-monday-com.s3.amazonaws.com/315151/resources/25252552/download%20%283%29.jpeg?response-content-disposition=attachment&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA4MPVJMFXILAOBJXD%2F20240315%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240315T204108Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=5ffcce0c07c81907a46a70d7bc060bebacc739c70156e6e0decd3fca82e19ea7",
"url": "https://example.monday.com/protected_static/315151/resources/234234234/sunset_lake.jpeg",
"isImage":"true"
}
]
}
Each file in the list contains the following fields:
- name - This field contains the name of the file.
- public_url - This field contains the public URL of the file. This URL can be used to download the file, even when not logged into monday.com. This URL is only valid for one hour. The main use is to download the file content in Power Automate for use in another system.
- url - This field contains the internal monday.com URL of the file. This URL can only be used to download the file when logged into monday.com. Power Automate cannot use this URL to download the file content in a flow, since when Power Automate runs a flow, it is not logged into monday.com. This URL does not expire like the public_url. The main use of the url field is to add a link to the file in another system, where the user who clicks the link is logged into monday.com (e.g. including the link in an email or a monday.com update).
- isImage - This field indicates if the file is an image. If the file is an image, the value is
true
. If the file is not an image, the value isfalse
.
The next section outlines how to use this file data in Power Automate.
Using File Data in Power Automate
Power Automate provides a "Parse JSON" action that can be used to parse the file data. This action can be used to extract the file URLs and names from the "Files" field. This makes it easier to use the data in your flows.
For this example, we will use the "When a column is changed" trigger to get the "Files" field of an item whenever the item's column changes. Then, we'll use the "Parse JSON" action to parse the "Files" field.
In the "Parse JSON" action, we'll use the "Files" field (output by the "When a column changes" trigger) as input for the "Content" field.
In the Schema field, we copy and paste the following JSON schema. This schema will define the structure of the "Files" field. You don't need to understand this schema, and can just copy and paste it as is for all of your file-based flows.
{
"type": "object",
"properties": {
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"public_url": {
"type": "string"
},
"url": {
"type": "string"
},
"name": {
"type": "string"
},
"isImage": {
"type": "string"
}
},
"required": [
"public_url",
"url",
"name",
"isImage"
]
}
}
}
}
Now that we've added the "Parse JSON" action, the name, public_url, url, and isImage fields are available to use in our next actions. Below, you can see the outputs of the "Parse JSON" action:
At this point, we can use the file data output from the "Parse JSON" action in two ways:
- We could use the "Body url" field, which contains the internal monday.com URL of the file, and add this file link to another system (such as sending it via an email or adding it to a monday.com update). If using the "url" field, remember that the URL can only be used to download the file when a user is logged into monday.com.
- We can also download the files using the "Body public_url" and add them to another system, like SharePoint. More details for how to do this are below.
Below, we outline how to use the file data in these two ways.
Option 1: Using a File Link in Another System (e.g. Email)
For this example, we'll use the "Body url" field to add the file link to an email.
To do this, we add the "Send an email notification" action to the flow. In the body of the email, we add the "Body url" field from the "Parse JSON" action. This will add the file link to the email.
When the recipient of the email clicks the link, they will be taken to the file in monday.com. They will need to be logged into monday.com to download the file.
Below is what our final flow looks like. The "For each" is added automatically by Power Automate to run the "Send an email notification" action for each file in the "Files" field.
Option 2: Downloading Files to Add to Another System (e.g. SharePoint)
For this example, we will download each file to eventually add to SharePoint.
Downloading each file can be done using the "HTTP" action in Power Automate. We add this action to the flow and use the "Body public_url" field from the Parse JSON action as the URI field. Then, we select the "GET" method. The rest of the fields can be left blank.
Below is what the flow looks like now. The "For each" is added automatically by Power Automate to run the HTTP action for each file in the "Files" field).
The HTTP action outputs the file content as a binary file. This can be used in a variety of different actions that take a binary file as input. For this example, we'll add the file to SharePoint.
To do this, we add the SharePoint "Create file" action to the flow and use the "Body" field from the HTTP action as the "File content" field. The "Body" field contains the actual file content in binary form.
For the file name, we can use what was output by the "Parse JSON" action, or we can add our own name. For this example, we'll use the name from the "Parse JSON" action, so that the file created in SharePoint matches the uploaded file name in monday.com.
Here's what our final flow looks like:
This flow will now download files from the "Files" field of an item when an item's column changes. It will then add those files to SharePoint.