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.
Or you can use this component as it already has this implementation
https://www.outsystems.com/forge/component-overview/3242/binarydata-client-side
Nikhil Gaur wrote:
Thanks Nikhil, simple trick, just assigned binaryData value to text type output variable solved the problem.
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.
Dileep Verma
I've provided a sample oml, check if that is what you need.
Pedro Neto wrote:
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.
Yes, even I was shocked when I saw this code in the component. I was not expacting it to be that simple :)
Excellent stuff! And it also works the other way around:
$parameters.binary = $parameters.base64;