1325
Views
8
Comments
Solved
Convert image Binary Data to Base64 in mobile client side or Javascript
Question

Hi,

I want to convert the image Binary Data to base64 without using server action "BinaryToBase64". Is there any client action or javascript code to convert binary data getting from upload control  to base64 that works offline .


Thanks,

Dileep.

2020-03-01 17-52-33
Nikhil Gaur
Solution

Or you can use this component as it already has this implementation

https://www.outsystems.com/forge/component-overview/3242/binarydata-client-side

2024-06-26 06-49-09
Dileep Kumar Verma

Nikhil Gaur wrote:

Or you can use this component as it already has this implementation

https://www.outsystems.com/forge/component-overview/3242/binarydata-client-side

Thanks Nikhil, simple trick, just assigned binaryData value  to text type output variable solved the problem.

2020-03-01 17-52-33
Nikhil Gaur

Hi Dileep,

I am not sure if any client action available in outsystems for this but you can use javascript to convert binarydata to base64 string. You can use below method

window.btoa(yourbinarydata);

or just 

btoa(yourbinarydata);

Assign its output to output variable of your js block and use in the client action for further processing.

2024-06-26 06-49-09
Dileep Kumar Verma

Nikhil Gaur wrote:

Hi Dileep,

I am not sure if any client action available in outsystems for this but you can use javascript to convert binarydata to base64 string. You can use below method

window.btoa(yourbinarydata);

or just 

btoa(yourbinarydata);

Assign its output to output variable of your js block and use in the client action for further processing.

Thanks Nikhil but I already tried this but what I observed its not returning the same base64 output as we are getting using server action BinaryToBase64.So when I am passing it not getting expected results what i was getting when converted using server action.


Thanks,

Dileep Verma


2019-12-01 23-50-25
Pedro Neto
Champion

Hi Dileep,

I've provided a sample oml, check if that is what you need.

BinaryToBase64ClientSide.oml
2024-06-26 06-49-09
Dileep Kumar Verma

Pedro Neto wrote:

Hi Dileep,

I've provided a sample oml, check if that is what you need.

Pedro, using 

btoa(decodeURI(encodeURIComponent($parameters.BinaryImageData)))

I am not getting the same output , what was getting using BinaryToBase64 for same image, getting encoded base64 text,  results the behaviour is not same.


Thanks,

Dileep Verma


2020-03-01 17-52-33
Nikhil Gaur
Solution

Or you can use this component as it already has this implementation

https://www.outsystems.com/forge/component-overview/3242/binarydata-client-side

2024-06-26 06-49-09
Dileep Kumar Verma

Nikhil Gaur wrote:

Or you can use this component as it already has this implementation

https://www.outsystems.com/forge/component-overview/3242/binarydata-client-side

Thanks Nikhil, simple trick, just assigned binaryData value  to text type output variable solved the problem.

2020-03-01 17-52-33
Nikhil Gaur

Hi Dileep,

Yes, even I was shocked when I saw this code in the component. I was not expacting it to be that simple :)

2022-04-27 06-05-22
Thomas Skødt

Excellent stuff! And it also works the other way around: 

$parameters.binary = $parameters.base64;

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.