2014-02-27 119 views
0

軒 任何想法如何下載文件在Ruby中我嘗試這一點,但它不是我的工作index.html.erb下載文件

我這樣做

require 'open-uri' 
def index 
File.open('/target/path/to/downloaded.file', "wb") do |file| 
    file.write open('http://example.com/your.file').read 
end 
end 

,但它仍然不是工作

回答

0

由send_file應該像這樣工作:

send_file "/target/path/to/downloaded.file", 
      :filename => "your.file", 

也有一些更高的對ms可用:

  :type => 
      :x_sendfile => true