Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com
I was recently conducting a training on Power Automate and there in came this question. How do I convert a byte array to base64 string in PowerApps.
After all there is a function in Power Automate – base64ToBinary which converts a base64 string to Binary. But there is no function like binaryToBase64 in Power Automate. If you are from C#, you would be thinking wish you had a method similar to Convert.ToBase64String in Power Automate too.
Well, I can understand the disappointment here. But frankly speaking the method is never needed. And it is because of that way Power Automate handles an incoming byte array.
For example you are reading a file from one drive and want to convert the binary file into Base64 string for further processing. You actually don’t need to. This is because when Power Automate will handle the incoming bytes, it will automatically convert the incoming bytes as Base64 with content type as “application/octet-stream”.
“$content-type”: “application/octet-stream”
And to get the content in Base64 format, you just need this expression – triggerBody()?[‘$content’]
Let’s see this with an example here.
I create a Manual trigger flow with “abcd” as my initial input parameter. Below is my flow definition
Nothing complex about the flow. Steps are explained below
I have to catch a form post from flash, and convert the octet stream into an image to save on the server. Any help would be greatly appreciated. Below is my code: byte imgBytes = new byte Request.InputStream.Length; using (BinaryReader br = new BinaryReader (Request.InputStream)) br.Read (imgBytes, 0, imgBytes.Length). Convert Octet-stream To Pdf Download Film Full Movie Terbaru Windows 8 Pro Build 9200 Activator Crack Download Express Rip Html5 Css3 Y Javascript Anaya Pdf Descargar 2014 Rubik Cube Solution Pdf In Malayalam Passport Deutsch 2 Klett Download Adobe Gana Songs In Tamil Abcd Hindi Movie Online.
- Convert the text into base64 string using expression – base64()
- Use the Compose operation to convert the base64 encoded string into binary using the base64ToBinary() expression.
- In the final step I assign the Binary input to a string variable
Let’s see what is the final output when we start with initial input – “abcd”.
Observe the Compose step where I used base64ToBinary() expression. As you can see, that the content is actually still in base64 format but the content-type has been changed to “application/octet-stream”.
In the final step when I am using the Output from from Compose Action and assigning it to a string variable, it is actually decoding the base64 text into plain text.
And that is why there is no function like binaryToBase64. After all the content is always in base64. The content-type reflects the type of content stored internally.
Hope this helps!
Debajit Dutta
(Microsoft MVP)
- As you may have guessed, everything is an octet stream, just a stream of these 8 bit computer building blocks. However, MIME RFC 2046 describes octet streams as ‘arbitrary binary data’.
- Octet Stream File Converter Online If the byte array contains fewer than 128 bytes, the Length field of the TLV triplet requires only one byte to specify the content length. If it is more than 127 bytes, bit 7 of the Length field is set to 1 and bits 6 through 0 specify the number.
- Just paste text in the form below, press Convert button, and you get oct text. Press button, get octal. No ads, nonsense or garbage. Works with Unicode and UTF8 as well. Announcement: We just launched Online Text Tools – a collection of browser-based text processing utilities.