07-14-2023 21:22 PM - last edited 07-14-2023 21:39 PM
When:
Whenever you need to transfer a file from one source to a destination without transferring the actual file (or you cannot do that due to restrictions), in those cases you need to use the Base64 actions.
Example 1; You need to store the photo of a person from your machine to a Database. You need not store the actual image into the database.
Example 2; You are making an API call and need to transfer a text file. You need not send the file.
Why:
You need to use the Base64 actions so that instead of the actual file, you can store the text representation of the file and Base64 action does exactly that.
Base64 encoding is used to encode data for storage or transmission because it is more efficient than storing or transmitting the data in its raw binary form. It also reduces the size of the data, which can be useful when transmitting data over a network or storing it on a disk. Consider the difference between storing an actual image in the database versus its encoded text format in the database column.
How:
Power Automate Desktop provides two actions for converting a file to Base64 and vice versa.
Convert file to Base64 (used usually at the Source):
The first action is used to convert a file to its corresponding Base64 encoded text.
This is the Sample.jpg that I have given in the above path.
On running the process, the Base64Text variable will have the corresponding encoded text.
Convert Base64 to file (used usually at the Destination):
The second action is used to convert a Base64 encoded text back to the original file.
Let's say, as in our Example 1, a database column stores the photo of a person in its encoded form.
At this point Power Automate Desktop will read that field and pass it in the below action to get the actual photo of the person.
Replace the %Base64Text% with the variable coming from the database column, as example.
The File Path should have the full path with file name and extension of the destination file.
After running the process, below is the Sample output.jpg file which is same as the original file above that was encoded.
Another example of making use of this action is while adding signatures to an Outlook email.
Refer direct link to an answer I have posted here. (Wait for the page to load and to jump to the direct post)
- Attached is a Desktop Flow with both the Base64 actions. Copy paste into a blank flow editor.
- This Flow is built in Version 2.33