我已經做到了這一點:強制從控制器操作下載公共目錄中的文件?
<% 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