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

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

HEATFreight
Kudo Collector
Kudo Collector

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,061)