I'm building a Sinatra app that needs to send files to the user that it has just downloaded from elsewhere (essentially a proxy).
Whilst I have the bulk of it working, I cannot get Sinatra to send the correct filename as specified in my code. The code I'm using is:
get '/' do
attachment file.name
headers['Content-Type'] = file.content_type
headers['Content-Disposition'] = 'attachment'
file.body
end
(file.body is the contents of the file)
How can I get Sinatra to use the filename I want?
headers["Content-Disposition"] = "attachment;filename=the_file.txt"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With