Reputation: 22240
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?
Upvotes: 3
Views: 1479
Reputation: 22240
headers["Content-Disposition"] = "attachment;filename=the_file.txt"
Upvotes: 5