You might need to add files to Power Automate Variables because the application can’t find the file independently. Or it might be that you want to add a specific file, not all files of the type you specify. Either way, this short (ish) video provides a detailed step-by-step guide on correctly adding files to Power Automate variables and later using the variables to pass the file to another action. The key points covered in the video guide are to:
- Ensure that you only store the base64 string element of file content in a string variable
- 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!