Permalink
Browse files

expose s3_permissions analoguous to s3_protocol

  • Loading branch information...
1 parent 3a6ca7d commit f40969342eec12c278f0cc890643c024d87af423 @momolog momolog committed Oct 20, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/paperclip/storage/s3.rb
@@ -184,6 +184,12 @@ def exists?(style = default_style)
end
end
+ def s3_permissions(style = default_style)
+ s3_permissions = @s3_permissions[style] || @s3_permissions[:default]
+ s3_permissions = s3_permissions.call(self, style) if s3_permissions.is_a?(Proc)
+ s3_permissions
+ end
+
def s3_protocol(style = default_style)
if @s3_protocol.is_a?(Proc)
@s3_protocol.call(style, self)
@@ -214,13 +220,11 @@ def flush_writes #:nodoc:
@queued_for_write.each do |style, file|
begin
log("saving #{path(style)}")
- s3_permission = @s3_permissions[style] || @s3_permissions[:default]
- s3_permission = s3_permission.call(self, style) if s3_permission.is_a?(Proc)
AWS::S3::S3Object.store(path(style),
file,
bucket_name,
{:content_type => file.content_type.to_s.strip,
- :access => (s3_permission),
+ :access => s3_permissions(style),
}.merge(@s3_headers))
rescue AWS::S3::NoSuchBucket => e
create_bucket

0 comments on commit f409693

Please sign in to comment.