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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (4,192)