class AWS::S3::Bucket
bucket = s3.buckets[‘mybucket’]
@example Getting an Existing Bucket
bucket = s3.buckets.create(‘mybucket’)
@example Creating a Bucket
Represents a single S3 bucket.
def ==(other)
-
(Boolean)- Returns true if the two buckets have the same name.
def ==(other) other.kind_of?(Bucket) && other.name == name end
def acl
-
(AccessControlList)-
def acl acl = client.get_bucket_acl(:bucket_name => name).acl acl.extend ACLProxy acl.bucket = self acl end
def acl=(acl)
-
(nil)-
Parameters:
-
acl(AccessControlList) --
def acl=(acl) client.set_bucket_acl(:bucket_name => name, :acl => acl) nil end
def as_tree options = {}
-
(Tree)-
Options Hash:
(**options)-
:append(Boolean) -- If true, the delimiter is -
:delimiter(String) -- The string that separates -
:prefix(String) -- Set prefix to choose where
Parameters:
-
options(Hash) --
Other tags:
- See: Tree -
def as_tree options = {} objects.as_tree(options) end
def delete
-
(nil)-
Other tags:
- Note: - the bucket *must* be empty.
def delete client.delete_bucket(:bucket_name => @name) nil end
def delete!
-
(nil)-
def delete! versions.each{|version| version.delete } delete end
def empty?
-
(Boolean)- Returns true if the bucket has no objects
def empty? versions.first ? false : true end
def enable_versioning
-
(nil)-
def enable_versioning client.set_bucket_versioning( :bucket_name => @name, :state => :enabled) nil end
def eql?(other_bucket)
-
(Boolean)- Returns true if the two buckets have the same name
def eql?(other_bucket) self == other_bucket end
def exists?
-
(Boolean)- Returns true if the bucket exists in S3.
Other tags:
- Note: - This method only indicates if there is a bucket in S3, not
def exists? begin versioned? # makes a get bucket request without listing contents # raises a client error if the bucket doesn't exist or # if you don't have permission to get the bucket # versioning status. true rescue Errors::NoSuchBucket => e false # bucket does not exist rescue Errors::ClientError => e true # bucket exists end end
def initialize(name, options = {})
(**options)-
:owner(String) -- The owner id of this bucket.
Parameters:
-
options(Hash) -- -
name(String) --
def initialize(name, options = {}) # the S3 docs disagree with what the service allows, # so it's not safe to toss out invalid bucket names # S3::Client.validate_bucket_name!(name) @name = name @owner = options[:owner] super end
def inspect
- Private: -
def inspect "#<AWS::S3::Bucket:#{name}>" end
def location_constraint
-
(String, nil)- Returns the location constraint for a bucket
def location_constraint client.get_bucket_location(:bucket_name => name).location_constraint end
def multipart_uploads
-
(MultipartUploadCollection)- Represents all of the
def multipart_uploads MultipartUploadCollection.new(self) end
def objects
-
(ObjectCollection)- Represents all objects(keys) in
def objects ObjectCollection.new(self) end
def owner
-
(String)- bucket owner id
def owner @owner || client.list_buckets.owner end
def policy
-
(Policy, nil)- Returns the bucket policy (if it has one),
def policy policy = client.get_bucket_policy(:bucket_name => name).policy policy.extend(PolicyProxy) policy.bucket = self policy rescue Errors::NoSuchBucketPolicy => e nil end
def policy=(policy)
-
(nil)-
Other tags:
- See: Policy -
Parameters:
-
policy() -- The new policy. This can be a string (which
def policy=(policy) client.set_bucket_policy(:bucket_name => name, :policy => policy) nil end
def presigned_post(options = {})
- See: PresignedPost -
def presigned_post(options = {}) PresignedPost.new(self, options) end
def suspend_versioning
-
(nil)-
def suspend_versioning client.set_bucket_versioning( :bucket_name => @name, :state => :suspended) nil end
def url
-
(String)- url to the bucket
def url if client.dns_compatible_bucket_name?(name) "http://#{name}.s3.amazonaws.com/" else "http://s3.amazonaws.com/#{name}/" end end
def versioning_enabled?
-
(Boolean)- returns +true+ if version is enabled on this bucket.
def versioning_enabled? versioning_state == :enabled end
def versioning_state
-
(Symbol)- the versioning state
def versioning_state client.get_bucket_versioning(:bucket_name => @name).status end
def versions
-
(BucketVersionCollection)- Represents all of the versioned
def versions BucketVersionCollection.new(self) end