thoughtbot/paperclip — pull request #769 by joshuaclayton (2012-03-02 20:10:22+00:00)
Title: Pass aditional parameters to S3 expiring urls

This adds functionality to add additional params to the querystring for S3
expiring URLs. The reason for this is if you want to override
response_content_type or response_content_disposition with expiring URLs, you
have to change Amazon's signature, which gets signed before adding additional
options to the querystring. Because it's added later, and because Amazon's
signature includes the full URL, the signature is bad and the request fails.

To use this feature:

has_attached_file :avatar,
:s3_url_options => { :response_content_disposition =>
"inline" }

Additionally, you can pass a lambda and it'll be evaluated when the URL is
generated. If, for example, the content type is incorrect in Amazon
(either empty or application/octet-stream), you can effectively cast the
response from Amazon as a particular content type.

has_attached_file :avatar,
:s3_url_options => lambda {|model| {
:response_content_type => model.avatar_content_type } }