cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gr8Britton
Frequent Visitor

Camera Control - Android using png but iOS using jpg

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Gr8Britton
Frequent Visitor

For others, the fix was in the Power Automate task.  I was given advice by PowerApps911.com who said to use dataURItoBinary(), instead of using base64ToBinary().  Instantly fixed the issue.

 

Thanks you PowerApps911.com!

View solution in original post

4 REPLIES 4
Gr8Britton
Frequent Visitor

Update:

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.

Gr8Britton
Frequent Visitor

New Update:

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.

Gr8Britton
Frequent Visitor

For others, the fix was in the Power Automate task.  I was given advice by PowerApps911.com who said to use dataURItoBinary(), instead of using base64ToBinary().  Instantly fixed the issue.

 

Thanks you PowerApps911.com!

View solution in original post

Hi,

 

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.

 

Regards,

 

Alex

 

-------

 

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.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (17,228)