Reputation: 39385
I have some PDF files in a public rails folder. I want to set the response header "content-disposition" to "attachment". I know I can create a controller to read the files and set the header myself, but is there some general application wide setting that i can enable/configure?
Thanks in advance.
-JP
Upvotes: 3
Views: 1667
Reputation: 33239
What cwninja said.
Assuming Apache as your front-end server:
<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
application/octet-stream
because application/pdf
doesn't force a download in IE sometimes.
Upvotes: 2
Reputation: 9768
Rails/Rack never sees requests to your public folder, your front end web server should handle these. Assuming you are using Apache you could use this approach.
Failing that you can move the files out of the way and use either a rack middleware or a controller as mentioned to handle the request.
Upvotes: 2