web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Camera Control - Andro...
Power Apps
Answered

Camera Control - Android using png but iOS using jpg

(0) ShareShare
ReportReport
Posted on by 26

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?

screenshot.png
Categories:
I have the same question (0)
  • Gr8Britton Profile Picture
    26 on at

    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 Profile Picture
    26 on at

    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.

  • Verified answer
    Gr8Britton Profile Picture
    26 on at

    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!

  • alrezac Profile Picture
    Microsoft Employee on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 481

#2
WarrenBelz Profile Picture

WarrenBelz 379 Most Valuable Professional

#3
11manish Profile Picture

11manish 291

Last 30 days Overall leaderboard