I am querying salesforce for some attachment data and it returns the data in binary format.
I have tried to convert the same to base64, but I have been quite unsuccessful so far. I have tried the btoa()
method but it returns the The string to be encoded contains characters outside of the Latin1 range.
error.
I tried to use the fileReader method i.e., readAsDataURL()
, it returns the base64 string but unfortunately that doesn't represent the image.
COuld you please help me out as to how to convert the binary form of the data to base64encoded string?
Edit Ultimately, I want to show the image on the webpage with the data I am getting which I am unable to do