나는이 짓을했는지 :컨트롤러 동작에서 공개 디렉터리에있는 파일을 강제로 다운로드 하시겠습니까?
<% 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"이겠지만 거기에 있습니다 –
(웹 서버가 실행되는) 사용자가 모두 액세스 할 수 있습니까? 디렉토리까지 파일로? –
나는이 게시물의 도움으로 모든 것을 리팩토링했다. http://harrylove.org/2008/12/22/protected-file-downloads-with-ruby-on-rails-and-paperclip 결국 send_file을 사용하시오. –