cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dexx3336
Level: Powered On

Save Image format changed from camera control?

Hi Expertise,

 

Recently i am facing an issue while saving the image as attachment in CRM captured by camera control from canvas app .

 

I saves the imag as jpeg format to collection from camera control. As camera control gives the URL as base64 string of captured image with the prefix “data:image/jpeg;base64,”. so, i replaced initial string with ""(blank) and saved into the CRM . the record has been saved but while opening the attachment from CRM ,it gives below error 

 

powerapp error1.png

 

After digging more, i found that the base 64 string of saved image from the camera control was like "/png" as shown below and not the "/jpeg" and i was replaing the initial string by considering it as "/jpeg",

powerapps image saved.png

In CRM these attachments are stored as jpg type as below:

 

pwoerapps saved images.png 

 

I followed the same steps earlier(before recent update) also but at that time i didn't face such issue.

 

can anyone of you let me know why this behaviour of mismatching of base64 string is happening after the recent updated of powerapps?

 

thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Save Image format changed from camera control?

Hi @Dexx3336,

 

Just from the error message, it told that the base64 string contains invalid characters.

"The input is not a valid base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "

 

Have you tried to save the image directly without doing any modification?

The image saved from the camera control could be saved directly to the image field of the CRM entity.

 

Besides, take a look at the following blog for how to "link" Image in CDS into Dynamics 365:

PowerApps - Working with Images Part 1

Part 2

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Save Image format changed from camera control?

Hi @Dexx3336,

 

Just from the error message, it told that the base64 string contains invalid characters.

"The input is not a valid base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. "

 

Have you tried to save the image directly without doing any modification?

The image saved from the camera control could be saved directly to the image field of the CRM entity.

 

Besides, take a look at the following blog for how to "link" Image in CDS into Dynamics 365:

PowerApps - Working with Images Part 1

Part 2

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Dexx3336
Level: Powered On

Re: Save Image format changed from camera control?

Thanks, @v-micsh-msft for a response.

 

I can not save the image captured from camera control directly to the CRM as it appends some string at its prefix like belowpowerapps image saved.pngMy requirement is to store the captured images as attachments in notes entity against OOB/custom entities so I have to replace unwanted string to store in notes.

 

Earlier i was getting "data:image/jpeg;base64," and now i am getting "data:image/png;base64,"unwanted string.

So I  used below code to replace the unwanted string. 

If(StartsWith(First(Image).fileBody,”data:image”),Replace(First(Image).fileBody,1, Len(Left(First(Image).fileBody,Find(“,”,First(Image).fileBody))),””),First(Image).fileBody)});
The conversion of unwanted string is resolved using above code. But now i stuck at another issue: Not able to create the attachment regarding any entity

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,138)