Decoding base64

I had been successfully using the following code to decode a document in order to use it in a chatgpt prompt:

// Decode Base64 to string
let decodedString = atob({{ getFileContents.data.base64Data }});

It seems to have stopped working though.

Is there a way to prevent uploads from encoding in the first place? If not, what's the best way to decode them?

Hi @Caleb_Zuniga,

First off, welcome and thanks so much for reaching out!

Retool automatically encodes files as Base64 to ensure compatibility with some APIs that expect binary data to be encoded as text in a specific format, such as Base64. The code you shared seems correct as we'd recommend:

let decodedString = atob(encoded_string);

("encoded_string" being your actual Base64 encoded string) - but it's a little odd that it stopped working after finding success. Are you aware of any other changes made in the same process?