2011-02-01 24 views

答えて

12

あなただけのこれらのヘッダを送信することを確認する必要があります。

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 
+0

+1、それを私にビートし、より良い説明を私があったより書く。 –

+0

ここに 'send_file'のための[docs](http://sinatra.rubyforge.org/api/classes/Sinatra/Streaming.html#M000022)があります。 – Phrogz

関連する問題