在Ruby代码中下载文件(Download file in Ruby code)
欣任何想法如何在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但它仍然无法正常工作
Hin Any ideas how to download File in Ruby i try this but it's not working
in my index.html.erb i do this
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 endbut it's still not working
最满意答案
send_file应该像这样工作:
send_file "/target/path/to/downloaded.file", :filename => "your.file",还有一些可用的参数:
:type => :x_sendfile => truesend_file should work like this:
send_file "/target/path/to/downloaded.file", :filename => "your.file",also there are a few more params available:
:type => :x_sendfile => true更多推荐
发布评论