Last Updated: February 25, 2016
·
1.16K
· Alexandr K

Paperclip amazon s3 serve html files.

Hello.

If for some reasons you decide to serve html files using s3 and paperclip gem you should use content-type and content-disposition header fields on uploading html file to the s3.

Example how to use s3_headers with paperclip gem:

has_mongoid_attached_file :item,
    s3_headers: proc { |instance|
      {}.tap do |hash|
        hash.merge!(
          content_disposition: 'inline',
          content_type:        'text/html'
        ) if File.extname(instance.path).include?('html')
      end
    }