我已经做到了这一点:强制从控制器操作下载公共目录中的文件?
<% response.headers['Content-Disposition'] = "attachment;
filename=somefile.txt" -%>
I am a text file!
我想迫使我的公用文件夹文件的下载没有透露的路径,所以我有一个控制器比检查一些PARAMS知道位置(我的公共文件夹),然后我想强制下载:
<% response.headers['Content-Disposition'] = "attachment;
filename=#{@invoice.file_name}" %>
How do I get the file content to be here rather than this text?
有没有办法做到这一点?
获取“无法读取文件/path/to/file.pdf”,但它在那里 – 2009-10-09 15:47:29
用户(您的Web服务器运行时)是否可以访问所有文件目录到文件? – 2009-10-09 16:03:35
我在这篇文章的帮助下重构了所有内容:http://harrylove.org/2008/12/22/protected-file-downloads-with-ruby-on-rails-and-paperclip,它最后使用send_file。 – 2009-10-09 17:12:01