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

Cant change it to .image it has to be media else it throws "it expects Text-type and i use a error-type"

hm want the image to have imgtype: base64value, name: image_name, timestamp: DatetimeNow. 

thats teh values i want for each image, so i can loop trough it in the power automate and send each image off to server 

Hi @langsem ,

 

Got it. Does it work?

ClearCollect(colBase64;
Dropcolumns(
AddColumns(imgCol;"Imgtype";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)

 

Sik 

is it jsonCol i shall store to a label? to see the base64?

Hi @langsem ,

 

If you want to see the base64 code of the image in collection, use this:

First(colBase64).Imagetype

 

JsonCol is a JSON script of the entire collection colBase64, not JSON for images.

 

Sik

hm something seems wrong. Because went i upload it to server i get a blank image.. and the url its very short to be base64

cbc60591ce4dca910787fcfbd76806/6

Hi @langsem .

 

Did you change to use UploadedImage1.Image if you worked with 'Add Picture' control?

If it still report that error-type error, try to change the collection name to create a brand new collection.

Sik

hmm now it just broke my entire app so nothing works . 

 

Ok lets me break it down for you. 

 

I have 5 add image controllers, where i upload a image from either camera or local library. I then after picking 1-5 images store them into a collection with value Imagetype: ( the base64 value its whats intended ), Name: image_name , Timestamp: Datetimenow. 

then when thats done i send the collection to power automate. 

Hi @langsem ,

 

OK, so what is DMG_SCHEME_BTN? Please share some snapshots.

Here is my steps:

First, use the following code to generate a image collection. here the Image field is binary type, we need to encode it to Base64.

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

Second, add a new column "Imagetype" to store the base64 format image, and delete the Image column.

ClearCollect(colBase64;
Dropcolumns(
AddColumns(imgCol;"Imgtype";Mid(JSON(Image;JSONFormat.IncludeBinaryData);25;Len(JSON(Image;JSONFormat.IncludeBinaryData))-25));"Image")
);;

 Third, convert the colBase64 to JSON script in order to pass the table to flow.

Set(JsonCol;JSON(colBase64;JSONFormat.IncludeBinaryData));; IMG_API.Run(SONR;reg;Jobbtype;FORSIKRING;JsonCol)

 

Which step went wrong? Please go to File - Collection to check the collection data.

Sik

Here u see. Green mark its the dmg_schem_btn ( its the add image conntroll ) and in the onselect prop i have the code shown in image 

then i have a btn that sends the information to flow ( marked with Red ) 

The orange marked one are the lbl to display the base64 i will delete that lbl later, its just for testing purpose now 

Step1.png

step2.png

step3.png

   

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,346)