Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow getting S3#bucket object for non admin users

  • Loading branch information...
commit bdcd8e343ebc343d5f6532cf3225f606200259a3 1 parent ece3079
@konstantin-dzreev konstantin-dzreev authored
Showing with 18 additions and 4 deletions.
  1. +18 −4 lib/s3/right_s3.rb
View
22 lib/s3/right_s3.rb
@@ -97,10 +97,24 @@ def buckets
# (section: Canned Access Policies)
#
def bucket(name, create=false, perms=nil, headers={})
- headers['x-amz-acl'] = perms if perms
- @interface.create_bucket(name, headers) if create
- buckets.each { |bucket| return bucket if bucket.name == name }
- nil
+ result = nil
+ if create
+ headers['x-amz-acl'] = perms if perms
+ @interface.create_bucket(name, headers)
+ end
+ begin
+ buckets.each do |bucket|
+ if bucket.name == name
+ result = bucket
+ break
+ end
+ end
+ rescue RightAws::AwsError => e
+ # With non root creds one can use bucket(s) but can't list them
+ raise e unless e.message['AccessDenied']
+ result = Bucket::new(self, name)
+ end
+ result
end
Please sign in to comment.
Something went wrong with that request. Please try again.