class AWS::S3::BucketCollection
#=> [‘bucket1’, ‘bucket2’, …]
s3.buckets.collect(&:name)
You can also use it to find out which buckets are in your account:
bucket = s3.buckets[‘mybucket’]
bucket = s3.buckets[:mybucket]
access:
You can get a handle for a specific bucket with indifferent
s3.buckets.create(:name => “mybucket”)
You can use this to create a bucket:
Represents a collection of buckets.
def [] bucket_name
-
(Bucket)
-
Parameters:
-
bucket_name
(String
) --
def [] bucket_name bucket_named(bucket_name) end
def bucket_named name, owner = nil
def bucket_named name, owner = nil S3::Bucket.new(name.to_s, :owner => owner, :config => config) end
def create bucket_name, options = {}
-
(Bucket)
-
Options Hash:
(**options)
-
:acl
(String
) -- Sets the ACL of the bucket -
:location_constraint
(String
) -- The
Parameters:
-
options
(Hash
) -- -
bucket_name
(String
) --
Other tags:
- Note: - If your bucket name contains one or more periods and it
def create bucket_name, options = {} # auto set the location constraint for the user if it is not # passed in and the endpoint is not the us-standard region. don't # override the location constraint though, even it is wrong, unless config.s3_endpoint == 's3.amazonaws.com' or options[:location_constraint] then constraint = case config.s3_endpoint when 's3-eu-west-1.amazonaws.com' then 'EU' when /^s3-(.*)\.amazonaws\.com$/ then $1 end options[:location_constraint] = constraint if constraint end client.create_bucket(options.merge(:bucket_name => bucket_name)) bucket_named(bucket_name) end
def each &block
-
(nil)
-
def each &block response = client.list_buckets response.buckets.each do |b| yield(bucket_named(b.name, response.owner)) end nil end