Taking a picture with PowerApps and sending to SharePoint with just Flow
/Less than one day after I wrote about Taking a picture with PowerApps and sending to SharePoint with help of Azure Functions - I was looking at Flow to do another thing with recurring calendar events, and reading about how Logic App's Workflow Definition Language can be used in Flow. Then as I scrolled down - I saw this: dataUriToBinary
This was the heart of the problem in converting PowerApp's camera image (Data URI) for SharePoint File upload (Binary). That I solved with an Azure Function.
And here it is, again, staring at me: dataUriToBinary()
And I know I'd have to write this new post.
Create the Flow from Template
Using Advanced Formula from Logic Apps Functions in Flow
https://docs.microsoft.com/en-au/azure/logic-apps/logic-apps-workflow-definition-language#functions lists the Logic Apps functions available to Flow. There are some tricks to make the syntax work - but they are all the same, so practice makes perfect. Also, there is a LOT of functions. So it should be fun.
Add Compose Action
Add "@dataUriToBinary( ... )" drag in Createfile_FileContent. It'll look OK at first, but if you try to Update flow, you'll get an error.
The template validation failed: 'The template action 'Compose' at line '1' and column '1947' is not valid: "The template language expression 'dataUriToBinary(@{triggerBody()['Createfile_FileContent']})' is not valid: the string character '@' at position '16' is not expected.".'.
Note 2018: the Flow designer has been changed since 2017, and the way to write this expression has changed.
Create a Compose action
In the dynamic content panel that pop up on the right, select expression editor
Type in dataUriToBinary(triggerBody()['Createfile_FileContent'])
Note, without the prefix @
Hit OK to write the expression into the Compose
Note: Once you save and come back, it won't show the " quotes anymore, and it isn't updateable.
Result
So that's all - DataURI to Binary conversion for PowerApps camera to go to SharePoint file.
In a way, I'm glad - even in my previous post I argued that data conversion should be native, and shouldn't require a developer. So this is kind of my wish come true.