Download file util corrupts PDF files?

I call an API endpoint that redirects me to a S3 pre-signed URL pointing to the file.
The response I get from Retool is an object with base64Binary field.

Before, I was able to just use utils.downloadFile to download PDF files. Now, I get a corrupted PDF file. I am able to download images without problems though

Here's the code for downloading the PDF files

const response = await get_attachment_api.trigger()
let contentData = response.base64Binary
let contentType = response.fileType
utils.downloadFile(contentData, "my_pdf", contentType)

I trigger that via a button and my browser should automatically download a file. Opening on the PDF viewer does not work. Upon inspecting the downloaded file from Retool, it has the following hex.
4A 56 42 45 52 69 30 78 4C 6A 4D 4B 4A 63 54 6C -> JVBERi0xLjMKJcTl

Asked ChatGPT and it says that "JVBERi0xLjMKJcTl" is a base64 encoded representation of %PDF-1.3. I tried decoding the base64Binary. Now, I can open the file but it is just blank. Here is the hex.
image

I tried downloading the file manually via Postman and it worked properly. It opened successfully and no blank pages. Here is the hex.
image

It seems like utils.downloadFile is doing something with the "base64Binary"?

Not sure what to do here but appreciate the help. Thank you!

Hi @james.c,
Can you try this instead:

const response = await get_attachment_api.trigger()
let contentData = response.base64Binary
utils.downloadFile({base64Binary: contentData}, "my_pdf", 'pdf')

This worked for me in downloading a base64 string using utils.downloadFile().

Let me know! :grinning: