In this Power Automate tutorial, I will explain how to convert base64 to an image file in Power Automate.
Base64 is a method of representing binary data like files or images using only ASCII characters. It is known as “base64” because it adopts a base-64 numbering system, which allows it to represent 64 different values.
Encoding data in base64 converts it into a series of letters, numbers, and symbols that are safe to store in text-based systems like email or web pages.
And It is necessary because not all devices can directly handle binary data; base64 encoding allows you to convert it into a format that can be easily stored.
Scenario:
I have a Microsoft Form called Equipment Allocation. This form contains the following columns:
- Equipment name- Text
- Equipment id-Text
- Allocated To-Text
- Allocated date- Date
- Equipment image- Upload file
So when a user will submit the form, the response details and File will store in the SharePoint list known as ‘Equipment Allocation,’ and then we send the email to whom it is allocated via Outlook. This list contains the below columns.
- Equipment name – Single line of text
- Equipment id -Single line of text
- Allocated To – Person
- Allocated date – Date
- Attachment – Attachments
Implementation:
- We will create an Automated cloud flow that will trigger when a form is submitted.
- Then we will get the File content from Ondrive. And we will convert the file content from base64 to binary.
- Then we will create an item in the SharePoint list based on the form response. Also, we add the attachment to the SharePoint list using converted file content.
- Then we will email the person to whom the Equipment is Allocated to via Outlook.
Now let’s create the flow using Power Automate, to convert base64 to an image.
Convert base64 to an image file using Power Automate
Here we will see how to convert base64 to an image file using Power Automate.
Before creating the flow, ensure you have completed the setup of Microsoft Forms and SharePoint list with the required column.
Step 1: Log in to Power Automate. Then click on Automated Cloud Flow.
Then provide the flow name and select the ‘When a new response is submitted‘ action. Then click on Create button.
Provide the below information after the “When a new response is submitted” trigger action is added to the flow page.
- Form id: Select the Form id from the dropdown.
Step 2: Now we get the response details, so click on the +New step -> select ‘Get response details‘ action. Then provide the below information:
- Form id: Select the Form id from the dropdown.
- Response id: Select the response id from the dynamic content
Step 3: Next, click the +New step -> select Parse JSON action. Then provide the below information:
- Content: Select the Equipment Image from dynamic content
- Schema: Get the JSON code from the above step, ‘Equipment image’. Then click on Generate from the sample, provide the code, and click on Done.
Step 4: Next, click the +New step -> select Initialize variable action. Then provide the below information:
- Name: Provide the name as File content
- Type: Select the type as a string
Step 5: When a Microsoft form is submitted, the file will be stored in the Onedrive in the below path. It can be different based on your form name.
/Apps/Microsoft Forms/Equipment Allocation/Question
So, we will get the file content, click on the +New step, and select Get File content using the path action. Then provide the below information:
- File path: Provide the below path. This will automatically add Apply to each action.
/Apps/Microsoft Forms/Equipment Allocation/Question/@{first(body('Parse_JSON'))?['name']}
Next, click on Add an action -> select Set variable action, then provide the below information:
- Name: Select the File content from the dropdown.
- Value: Provide the below expression to get only content.
body('Get_file_content_using_path')['body']['$content']
Step 6: Now, we will convert file content (base64) to binary. So, click on the +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
base64ToBinary(variables('File content'))
Step 7: Next, click on the +new step -> select Compose action (Allocated Date). Provide the below information:
Inputs: Select Allocated Date from dynamic content.
Step 8: Now we get the user email, i.e., Allocated to, because the name we have provided in the form is in simple text. So, click the +New step -> select Search for users (V2) action. Then provide the below information.
- Search Term: Select the Allocated to from dynamic content.
Step 9: Now we will create an item in the SharePoint list, so click on the +New step -> select Create Item action. Then provide the below information:
- Site address: Select or Provide the SharePoint site address
- List name: Select the List.
- Title: Select the Equipment id from dynamic content
- Equipment name: Select the Equipment name from the dynamic content
- Allocated Date: Select output from dynamic content
- Allocated to: Select an email from dynamic content. This will automatically add Apply to each action.
Next, we will Add an attachment, so click on the +New step -> select Add attachment action. Then provide the below information:
- Site address: Select or Provide the SharePoint site address
- List name: Select the List.
- Id: Select the Id from the dynamic content
- File name: Provide the below expression to get the file name:
first(body('Parse_JSON'))?['name']
- File content: Provide the output -Compose as File content
Step 10: Now we will send an email, so click on the +New step -> select ‘Send an email (V2)’ action. Then provide the below information:
- To: Select the Email from dynamic content. That will automatically add Apply to each action
- Subject: Provide the subject of an email.
- Body: Provide the body of an email.
Now click on the Show Advanced option; in the Attachment section, provide the information:
- Attachment name -1: Provide the below expression:
first(body('Parse_JSON'))?['name']
- Attachment content: Select the output -Compose from dynamic content.
Step 11: Now, run the flow manually. To trigger the flow, fill out the form and click on Submit.
The flow will run, and the item is created in the SharePoint list.
Now, you can see the email in Outlook is look like below, especially the attachment:
Conclusion
In this Power Automate tutorial, we saw how to convert base 64 to an image with an example using Power Automate or Microsoft flow.
You may also like:
- Create an Array from SharePoint list Items using Power Automate
- Get Attachments from a SharePoint list item using Power Automate
- Power Automate Filter Query Operators
- Import Data from Excel to a SharePoint list using Power Automate
- Convert HTML to PDF in Power Automate
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.