cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
langsem
Post Patron
Post Patron

Encode base64

Hello i have an application where i upload multiple images with powerapps and power automate to a server. The server requires base64 plane text ( just the base64 value ) how can this be done in power apps and power automate ? The images has also nametag, timestamp and are stored in a collection before shipped of to power automate for then to be posted to server. 

27 REPLIES 27

Hi @langsem ,

 

First, move the collect formula to OnChange property of DMG_SCHEME_BTN, rather than OnSelect property, and modify it as follows.

Collect(imgCol;({Name:"Skademelding.jpeg"; Image:DMG_SCHEME_IMG.Image; timeStamp: Now()}))

This is because  DMG_SCHEME_BTN.Media store the temporary blob URL of the image, but the DMG_SCHEME_IMG.Image store the binary file of image.

Then set the OnSelect of Send button:

ClearCollect(colBase64;DropColumns(AddColumns(colImg;"Base64";Mid(JSON(Image;JSONFormat.IncludeBinaryData);25;Len(JSON(Image;JSONFormat.IncludeBinaryData))-25));"Image"));;
Set(JsonCol;JSON(colBase64;JSONFormat.IncludeBinaryData));; IMG_API.Run(SONR;reg;Jobbtype;FORSIKRING;JsonCol)

 The Text of Label: 

Last(colBase64).Base64

 

Here are my test result:Snipaste_2020-10-07_10-04-28.pngSnipaste_2020-10-07_10-04-46.png

Sik

 

When changing to onchange trigger i get the same error when using .image. Shall i put the aciton on the image itself or the btn ?

Hi @langsem ,

 

Ensure it is DMG_SCHEME_IMG.Image.  (ImageControlName.Image)

The code must be put on the OnChange event of DMG_SCHEME_BTN

Sik

Yes found it out, but format its wrong 😞 so not sure if its throwing just the base64 value

Found the issue it was missing a / at start. how can i include it ?

Hi @langsem ,

 

Please check the Mid formula which is used for extracting the base64 string. change 25 to 24 to see if it works?

Mid(JSON(Image;JSONFormat.IncludeBinaryData);24;Len(JSON(Image;JSONFormat.IncludeBinaryData))-24)

 Sik

View solution in original post

could i ask, is it possible to save the image url also? and convert it to jpg even tho its a png ?

HEATFreight
Advocate III
Advocate III

Is there a way to do this for a text string, like the time in zulu format: 2021-10-25T17:09:00Z because the Power Apps SharePoint connector converts text recognized as a time format into a different format: 10/24/2021 18:09:00, which will be interpreted by my API as a local time! If I could just encode base64 and decode later within Power Automate, I could guarantee no funny business with my perfectly formatted zulu time string. Without the Z at the end, the API I am connecting to will regard it as a local time. The SharePoint connector in PowerApps converts to an invalid format as far as I can tell, for my use case anyway. It won't just let a time string be a string.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,866)