Permalink
Browse files

For the Paperclip plugin, make Content-Disposition more useful by all…

…owing a proc to be given.
  • Loading branch information...
1 parent 339acce commit ba1c7456b79c67a36cc3625b2a95d3c439f84ea3 @chewi chewi committed May 21, 2011
Showing with 6 additions and 1 deletion.
  1. +6 −1 extra/s3_paperclip.rb
View
@@ -74,6 +74,11 @@ def s3_host_alias
@s3_host_alias
end
+ def content_disposition(style = default_style)
+ cd = @s3_headers[:content_disposition]
+ cd.respond_to?(:call) ? cd.call(self, style) : cd
+ end
+
def parse_credentials creds
creds = find_credentials(creds).stringify_keys
(creds[RAILS_ENV] || creds).symbolize_keys
@@ -130,7 +135,7 @@ def flush_writes #:nodoc:
object.storage_class = @s3_storage_class
object.content_type = instance_read(:content_type)
object.cache_control = @s3_headers[:cache_control]
- object.content_disposition = @s3_headers[:content_disposition]
+ object.content_disposition = content_disposition(style)
object.content_encoding = @s3_headers[:content_encoding]
object.save
rescue ::S3::Error::ResponseError => e

0 comments on commit ba1c745

Please sign in to comment.