Search code examples
ruby-on-railsruby-on-rails-3paperclip

Setting Content-Disposition to attachment using Ruby on Rails and Paperclip


I have a – hopefully small – problem.

I am using Ruby on Rails and Paperclip to handle file uploads. Now I want to automatically set the Content-Disposition header to "attachment" so that when the user clicks a link, the file is downloaded instead of shown directly in the browser.

I found the following solution for Amazon S3: Download file on click - Ruby on Rails

But I don't use S3.
Can anybody help?


Solution

  • According to this link, you can do the following:

    <Files *.xls> ForceType application/octet-stream Header set Content-Disposition attachment </Files> 
    <Files *.eps> ForceType application/octet-stream Header set Content-Disposition attachment </Files>