+ Start a Discussion
ethanoneethanone 

Convert VF/Apex AWS S3 Uploader to LWC

I'm trying to convert a working VF/Apex AWS S3 Uploader to a LWC and I need to translate the Apex code to JS.

On the Apex side I'm using
String EncodedPolicy = EncodingUtil.base64Encode(Blob.valueOf(Policy));

On the JS side, i've tried
let EncodedPolicy = btoa(Policy);
and given the same Policy, I don't get the same result.

What is the proper way to encode the policy?
ShirishaShirisha (Salesforce Developers) 
Hi ethanone,

Greetings!

Can you please try the below sample JS code for encoding the policy:

var res = encodeURI(Policy);

Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.

Warm Regards,
Shirisha Pathuri