5
<audio>
ブラウザでChromeを開く代わりに、http://foobar.com/song.mp3をsong.mp3
としてダウンロードします。ブラウザを開く代わりにファイルをダウンロードするようにしてください
どうすればこの問題を解決できますか?
<audio>
ブラウザでChromeを開く代わりに、http://foobar.com/song.mp3をsong.mp3
としてダウンロードします。ブラウザを開く代わりにファイルをダウンロードするようにしてください
どうすればこの問題を解決できますか?
あなただけのこれらのヘッダを送信することを確認する必要があります。
Content-Disposition: attachment; filename=song.mp3;
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
send_file
方法はあなたのためにそれをしない:
get '/:file' do |file|
file = File.join('/some/path', file)
send_file(file, :disposition => 'attachment', :filename => File.basename(file))
end
+1、それを私にビートし、より良い説明を私があったより書く。 –
ここに 'send_file'のための[docs](http://sinatra.rubyforge.org/api/classes/Sinatra/Streaming.html#M000022)があります。 – Phrogz