Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
expose s3_permissions analoguous to s3_protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
momolog committed Oct 20, 2011
1 parent 3a6ca7d commit f409693
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/paperclip/storage/s3.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f409693

Please sign in to comment.