for Microsoft Power Automate and Azure logic apps

Adding Files to Power Automate Variables

By Jay Goodison

23rd July 2021

Adding Files to Power Automate Variables

This short (ish) video provides a detailed step by step guide on how to correctly add files to Power Automate variables and later use the variables to pass the file to another action. The key points covered in the video guide are to:

  1. Ensure that you only store the base64 string element of file content in a string variable
  2. Wrap string variables containing base64 strings in the base64ToBinary() expression when passing to a ‘File Content’ property

Adding a File to Power Automate Variable

If the ‘File Content’ you are passing to a variable is structured as follows:

Then you must use the following expression to write the file into the variable: base64()

This ensures that only the base64 element of the structured file content is written into the variable.

If the ‘File Content’ you are passing to a variable is structured as follows, i.e. just a base64 string:

Then you must use the following expression to write the file to the variables: string()

This ensures that only the base64 is correctly preserved when written into the variable:

Sending a File Variable to an Action

Assuming the variable only contains a base64 string (as per this article), you must use the following expression when sending the variable to an actions ‘File Content’ property: base64ToBinary()

Finally

We hope you’ve found this guide useful, and as ever, please share any feedback or comments – all are welcome!