Rya*_*nce 1 ruby-on-rails header
我这样做了:
<% response.headers['Content-Disposition'] = "attachment;
filename=somefile.txt" -%>
I am a text file!
Run Code Online (Sandbox Code Playgroud)
我想在我的公共文件夹中强制下载文件而不显示路径,所以我有一个控制器而不是检查一些参数来知道我的文件的位置(在我的公共文件夹中)然后我想要强制下载:
<% response.headers['Content-Disposition'] = "attachment;
filename=#{@invoice.file_name}" %>
How do I get the file content to be here rather than this text?
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?
我认为send_file会做你想要的.
send_file '/path/to.file', :type => 'text/plain', :disposition => 'inline'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2853 次 |
| 最近记录: |