Converting Image files such as png, jpg, tiff to base 64

I want to convert image files to base 64 using js policy.

I have used crypto "crypto.base64(crypto.asBytes(FileContent));"

and other one

given by @anilsagar

"https://community.apigee.com/questions/25474/javascript-btoa.html"

I have tried both of them, for .txt files they are converting correctly.

But for image files the converted base64 string is not correct.

Please suggest any js code for converting imge files to base64

0 2 2,104
2 REPLIES 2

The JS callout doesn't handle binary bytestreams very nicely.

You can do base64 encoding using a python script.

Or this Java callout

https://github.com/DinoChiesa/ApigeeEdge-Java-Simple-Base64

Hi @Dino-at-Google, i have tried with the link you have provided in my eval account. The converted base64 code is not correct , i have cross checked base64code with the online image-to-base64 websites.

Below is the proxy i am using apibase64-rev1-2019-06-08.zip. please check

Thanks for the reply.