2011-02-01 19 views

Odpowiedz

12

Wystarczy upewnić się, aby wysłać te nagłówki:

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

Sposób send_file zrobi to za ciebie:

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

+1 beat mnie do niego i to znacznie lepiej niż ja wyjaśnienie pisanie. –

+0

Tutaj są [dokumenty dla 'send_file'] (http://sinatra.rubyforge.org/api/classes/Sinatra/Streaming.html#M000022). – Phrogz

Powiązane problemy