Like all other Power Automate connectors, the Encodian connector for Microsoft Power Automate (Flowr) and Azure Logic Apps receives and sends files as Base64 encoded strings. This is important to understand when working with files in Power Automate and Logic Apps.
A common misconception is that an action performed by a Power Automate connector (like Encodian) is performed in situ, i.e. the connector accesses a file directly and performs the configured action. This is not the case: you need to configure your Flow to obtain the target file from its storage location, pass this file to a connector for processing, which would then return the processed file… then finally, you would do something with the file, like adding to SharePoint.
Consider this example which shows how to convert a document stored within SharePoint to PDF using the Encodian connector:
A file copy is retrieved from SharePoint and sent to Encodian for processing. The document is leaving the Microsoft 365 tenancy to be processed. This is not specific to Encodian; this is how connectors interoperate within Microsoft Power Automate.
Encodian’s infrastructure is hosted 100% within Microsoft Azure data centres. Your data will never leave a Microsoft data centre. Where required, we can provide a ‘Dedicated Connector‘ where a copy of the Encodian connector is deployed directly into your Azure tenant, therefor data never leaves your Microsoft cloud tenancy.
Let’s explore the previous example in more detail to understand how the file is processed:
Hopefully, this screenshot depicts the data flow succinctly and exposes some of the clever processing performed by Microsoft behind the scenes.
You’ll notice in the first completed action that the ‘File Content‘ property returned by the SharePoint ‘Get file content‘ action contains more than just a Base64 string:
The ‘File Contents‘ schema explained:
{ "$content-type": "<MIME Type>", "$content": "<Base 64 String>" }
$content-type is a MIME Type (or media type), which helps to describe the document format; $content is the Base 64 string, the actual file encoded.
You may also have noticed that the data sent to the Encodian connector in the example is just the $content value and not the total ‘File Content’ property value:
Microsoft Power Automate is intelligently processing data to ensure that data is sent in the correct format. This is a super important concept, especially when working with documents using different actions.
This processing is also performed on the value returned by the Encodian action, whereby Microsoft Power Automate is automatically transposing the Base64 string into a complete ‘File Contents‘ property.
For most simple scenarios, this isn’t something you need to consider. Still, when you are processing files received in different ways (HTTP Post, PowerApps) or collating an array of documents for merging, things can go awry… very awry!
The critical consideration is that Power Automate performs pre/post-processing on Base64 strings to ease interoperability. Occasionally, you need to add extra steps to your flow to ensure that files are not corrupted en route. For example, consider this example of building an array of documents:
We’ve already seen that Microsoft dynamically extracts just the $content value… so the ‘Append to array variable‘ should append this:
"file": "<Base 64 String>"
But it doesn’t – see below:
Power Automate is reacting to the destination and, in this instance, has decided that an array variable expects binary data and has tried to append a binary value. Thankfully, we can use expressions to override the default behaviour, and this example shows how the Base64() expression is used to inform Power Automate to provide data in the desired format:
And the resulting output is now correct:
If you are appending files to Power Automate array variables, review the following video as there are some gotcha’s to be aware of!
Hopefully this post has provided some additional insight into how Microsoft Power Automate processes files. Should you experience issues, you should always check the run history and validate that data is passed correctly… it’s usually apparent when documents (File contents) are being given in an incorrect format.
We hope you’ve found these quick tips helpful, and as ever, please share any feedback or comments – all are welcome!
UPDATE: We’re excited to announce some significant updates to Flowr for Power Automate! As of October 2024, we’ve improved by updating action names and splitting Flowr’s central Power Automate connector into nine specialized connectors. These changes will make your workflow faster, smoother, and more efficient. The new action names are more precise and intuitive, saving you time, while the focused connectors enhance performance and flexibility. This update also helps future-proof the platform for even more powerful features. Check out our updated action names blog.
Managing Director