Table of Contents
When working with SharePoint lists, image columns are a common way to store photos or signatures. However, to get file content of image column in Power Automate a few steps are required and can be less straightforward than we may think, mainly because the place where the images are stored has changed over the years.
In this blog we will show how to use Power Automate to extract the file content of an image stored in an image SharePoint column.
If we inspect the SharePoint site page when we click on a image, we will see that behind the scenes, SharePoint is calling the following URL to extract the image content:
https://yoursharepointsite.sharepoint.com/sites/BootcampDemos/Lists/imagen/Attachments/4/Reserved_ImageAttachment_%5B3%5D_%5Bimg%5D%5B32%5D_%5Bc1f410a021a843358ea73b04a032cd92%5D%5B1%5D_%5B1%5D.png
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
We can conclude the following:
- Images are stored under the following path
Lists/{sharepoint-column-name}/Attachments/{item-id}/{file-name}
- The image is saved with the following name:
Reserved_ImageAttachment_{random-name}
We will use a combination of HTTP SharePoint requests and out-of-the-box get file content actions in Power Automate to extract the content of the image using above information.
Step 1. Create list and column
For this blog, we will create a simple SharePoint list with a single image column. This is how it looks after creating.
Step 2. Create Power Automate workflow and add the trigger
Time to start with the workflow. For this example, we will use the “When an item is created” trigger.
Make sure to select the SharePoint site and the list name.
Step 3. Get assigned image file name
Add a new action below the trigger and look for the “Send an HTTP request to SharePoint” action. This action is required because we will use it to extract the name of the file that SharePoint assigned when saving it to site.
Set up the action as follows:
Site address: Select SharePoint site
Method: GET
Uri: _api/lists/getbytitle('{your-list}')/items(@{triggerBody()?['ID']})/{your-image-column}
This action will return the following:
{"d":{"img":"{\"fileName\":\"Reserved_ImageAttachment_[3]_[img][32]_[64a589a08de24834a4666422eac5710a][1]_[1].png\",\"originalImageName\":\"Copy of Thumbnail Comunidad (2)\"}"}}
We are interested in the fileName attribute that is contained in the results. We could use a Parse JSON action to extract this but we can also the json() action in Power Automate to parse the result without having to add more actions to our flow.
json(body('HTTP_Request_Get_image_column_details')?['d']?['img'])?['fileName']
Finally, let’s rename the action: HTTP Request Get image column details. This is how the flow should look:
Step 4. Get file content
Lists/{your-list}/Attachments/{item-id}/json(body('HTTP_Request_Get_image_column_details')?['d']?['img'])?['fileName']}
Lists and Attachments will not change. Make sure to update your list name, the ID of the item. If you’re using a different step name for the HTTP action, make sure to change the following text by your action name:
‘HTTP_Request_Get_image_column_details’
This is how the flow should look:
Step 4. Test and add any other required step
All set! With these simple steps we are able to extract the file name when the image was stored in SharePoint, and using this name, we use the file path to extract the content. We are ready to keep adding actions such as putting into a PDF or sending them by email.
How our Power Automate Development services can help
Whether you’re looking for help with SharePoint lists or any other Power Automate automations or workflows, our Power Automate consulting services could be of help.
Contact us and we’ll be more than happy to have a conversation and see how we can be of help to your team.