You just need to send these headers:
Content-Disposition: attachment; filename=song.mp3;
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
The method send_filedoes this for you:
get '/:file' do |file|
file = File.join('/some/path', file)
send_file(file, :disposition => 'attachment', :filename => File.basename(file))
end
source
share