I am using the camera control to take a picture of a handwritten timesheet and automatically upload to a specific SharePoint folder. I have a power app working fine and it calls a Flow to handle the save. Here is how it works:
The user takes the picture and then taps an icon to save. The OnSelect for the icon is:
'UploadClientTimesheet-SavePhoto_1'.Run("ClientTimesheet-"&Text(Today(),"[$-en-US]mm_dd_yyyy")&".png", Substitute(Camera1.Photo,"data:image/png;base64,",""),Substitute(Camera1.Photo,"data:image/jpg;base64,","")); Notify("Your Timesheet has been submitted.", NotificationType.Success)
NOTE: The second substitute, Substitute(Camera1.Photo,"data:image/jpg;base64,",""), was my attempt to set it as png and jpg and try to have the Flow use the correct one.
When the Flow runs, it works fine for Android (which is saving the picture as png.) Apple iOS fails with, "'The template language function 'base64ToBinary' was invoked with a parameter that is not valid. The value cannot be decoded from base64 representation.'." After looking at the results, I found that an Android picture comes in fine with only the binary data but iOS sends:
"data:image/jpeg;base64, with the binary data after that, which I presume is because iOS is taking the picture as jpg.
I tried a condition asking if the FileContent starts with "data:image/jpeg;base64 to process as jpg but could not get it to match that correctly.
Anyone have any suggestions? Or, is there a way to do this directly in PowerApps without the Flow?
Solved! Go to Solution.
I was able to match the condition properly. In Power Apps, I tried to capture a filename and content as png and then another filename and content as jpg. In the flow, if it started with jpg, then I saved the file with .jpg file name. It worked but the file was inaccessible and stated it was not a jpg. So, this does not work. Going back to the simple PNG and trying again.
I recreated the Flow to clean up the number of parameters need to be supplied. It now only needs the FileName and the Content. In the Flow, I created an if statement to see if it started with data:image/jpeg and if so, name the file with .jpg extension. This all worked except the jpg file generated could not be opened. If it does not start with that, it does the base64ToBinary to png. This still works fine.
So, I'm stuck. Any help would be greatly appreciated.
Thanks for your follow up post! I am glad that you were able to get this figured out. Hopefully this will prove useful for future communities users who are having similar issues.
Community Support Team _ Alex Rezac
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out new user group experience and if you are a leader please create your group
We are excited to announce that Demo Extravaganza for 2021 has started!
On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks
Did you miss the call? Check out the recording here!