You just need to make sure to send these headers:
Content-Disposition: attachment; filename=song.mp3;
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
The send_file
method does it for you:
get '/:file' do |file|
file = File.join('/some/path', file)
send_file(file, :disposition => 'attachment', :filename => File.basename(file))
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…