Download a data-stream directly to file

I'm new to Retool so this might be a duplicate. I'm shipping a "Download Export" feature to my clients and struggling to get Retool to just handle the response directly to the browser without storing its content in memory.
As per this topic and many more, the only way to download a file is to get the response body and handle it to utils.downloadFile as a Base64 string, which means that before being downloaded, the content of the file is entirely stored in the browser runtime memory.
This is suitable for small files, but an export can be very heavy (several hundreds of Mb, in certain cases), so this feature needs the ability to just handle the response to the browser (with the content-disposition header properly set to attachment) and let the browser treat the response as a byte-stream and download it directly to a file, just like when we click on a "Download" link :slight_smile:
How can we achieve it with Retool?

Thank you for your help!

Hi @Luca_Marchesini!

Folks have played around with doing this using a custom component with downloads enabled:

The above works to download a file through a signed URL generated by S3 for instance.

Could something like that work for you?

Hey, thanks @Kabirdas !
This still seems to retrieve the while response in-memory before saving its content to a file, which is still not suitable for big contents, but I'll investigate it. Custom components might be the key, though, in order to have just a classic a tag, which just lets the browser do the job without having Retool intercept the response from the server.
Which might something that already exists in Retool and I'm not aware of it... :slight_smile:

:thinking: how are you accessing the file? If you can generate a URL where the response will have the correct content-disposition you may just be able to use a "Go to URL" event handler on a button.