Downloading large Base64 files

I am working on downloading a PDF from AWS S3 as a Base 64 encoded string. I have it working for smaller files but it is failing for files over a certain size. I don't know JavaScript that well so I'm a little over my head on this. Below is my code.

In case it is relevant, my intention isn't to save the file to the host computer but rather store the Base 64 string to my SQL database.

The code below runs as a JavaScript query.

const getBase64FromUrl = async (url) => {
const data = await fetch(url);
const blob = await data.blob();
return new Promise((resolve) => {
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = () => {
const base64data = reader.result;
resolve(base64data);
state_base64file.setValue(base64data)

}

});
}

return getBase64FromUrl(qMergePDFs.data.primary_url).then(console.log)

Thank you!!!

Hey @pdamato!

Glad to hear it's working for smaller files. How large are the files that are failing?