Set content allocation to public file types in Rails?

I have PDF files in the public rails folder. I want to set the response header of "content-disposition" to "attachment". I know that I can create a controller for reading files and configure the header myself, but is there any general general application parameter that I can enable / configure?

Thanks in advance.

-JP

+3
source share
2 answers

Rails / Rack never sees requests for your shared folder, your front-end web server should handle them. Assuming you are using Apache, you can use this approach .

, .

+2

cwninja.

, Apache :

<FilesMatch "\.(?i:pdf)$">
  ForceType application/octet-stream
  Header set Content-Disposition attachment
</FilesMatch>

application/octet-stream, application/pdf IE.

+2

Source: https://habr.com/ru/post/1721126/


All Articles