2011-02-01 16 views

cevap

12

Sadece bu başlık göndermek emin olmak gerekir:

Content-Disposition: attachment; filename=song.mp3; 
Content-Type: application/octet-stream 
Content-Transfer-Encoding: binary 

send_file yöntem sizin için yapar:

get '/:file' do |file| 
    file = File.join('/some/path', file) 
    send_file(file, :disposition => 'attachment', :filename => File.basename(file)) 
end 
+0

+1 Beni ona yendi ve çok daha iyi bir açıklama benden daha yazıyor. –

+0

İşte [gönder_dosyası 'için belgeler] (http://sinatra.rubyforge.org/api/classes/Sinatra/Streaming.html#M000022). – Phrogz

İlgili konular