Ruby on rails RubyonRails:音频/mp3内容头下载
如何在ruby/rails中设置下载的标题 在php中,我为mp3下载设置了如下标题:Ruby on rails RubyonRails:音频/mp3内容头下载,ruby-on-rails,ruby,Ruby On Rails,Ruby,如何在ruby/rails中设置下载的标题 在php中,我为mp3下载设置了如下标题: header("Content-Transfer-Encoding: binary"); header("Content-type: audio/mp3"); header("Content-Disposition: attachment; filename=\"$songname.mp3\""); header("Content-Length: " . $size);
header("Content-Transfer-Encoding: binary");
header("Content-type: audio/mp3");
header("Content-Disposition: attachment; filename=\"$songname.mp3\"");
header("Content-Length: " . $size);
@readfile("http://example.com/12345.mp3");
似乎应该有一个简单的解决办法
我确实发现:
response.headers['Content-type'] = 'Content-type: audio/mp3'
但我不确定readfile将如何/在何处发挥作用以及其他头文件
谢谢 找到了答案。控制器中应使用send_文件
def download
send_file "/path/to/file.mp3", :type=>"audio/mp3", :filename => "filenamehere.mp3"
end
rails进程限制还有一些其他考虑因素:
请看这里:
另外,发送文件