Simple non-streaming download with different filename

I’m trying to make download available through Rails.
I know there’s send_data / send_file method in rails, but they’re
streaming download so that the process serving file is kept alive.
Web hosting services usually do not allow a long-lived process and
therefore download always fails.(It’s disconnected around 2-3 minutes)

So, I want to just use http header to download file.
However, I want the file’s name to be different from the physical file
name in the server.

I know that it can be done using ‘Content-Disposition’ header.
So, I tried this…

def download
response.header[‘content-type’] = ‘application/force-download’
response.header[‘content-disposition’] = ‘attachment; filename=“new file
redirect_to URL_OF_FILE

however, it just redirects to the file and the download(save) dialog box
shows the physical file name, not the new file name that I want to show
to user.

What should I do to make it possible?

Thank you in advance.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs