A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Bucket.html below:

Bucket — AWS SDK for Ruby V2

You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::S3::Bucket Instance Attribute Summary collapse Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details #initialize(name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object Instance Attribute Details #creation_date ⇒ Time

Date the bucket was created.

Instance Method Details #clear! ⇒ void

This method returns an undefined value.

Deletes all objects and versioned objects from this bucket

14
15
16
# File 'aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb', line 14

def clear!
  object_versions.batch_delete!
end
#create(options = {}) ⇒ Types::CreateBucketOutput

Creates a new S3 bucket. To create a bucket, you must register with Amazon S3 and have a valid AWS Access Key ID to authenticate requests. Anonymous requests are never allowed to create buckets. By creating the bucket, you become the bucket owner.

Not every string is an acceptable bucket name. For information about bucket naming restrictions, see Working with Amazon S3 buckets.

If you want to create an Amazon S3 on Outposts bucket, see Create Bucket.

By default, the bucket is created in the US East (N. Virginia) Region. You can optionally specify a Region in the request body. You might choose a Region to optimize latency, minimize costs, or address regulatory requirements. For example, if you reside in Europe, you will probably find it advantageous to create buckets in the Europe (Ireland) Region. For more information, see Accessing a bucket.

If you send your create bucket request to the s3.amazonaws.com endpoint, the request goes to the us-east-1 Region. Accordingly, the signature calculations in Signature Version 4 must use us-east-1 as the Region, even if the location constraint in the request specifies another Region where the bucket is to be created. If you create a bucket in a Region other than US East (N. Virginia), your application must be able to handle 307 redirect. For more information, see Virtual hosting of buckets.

When creating a bucket using this operation, you can optionally specify the accounts or groups that should be granted specific permissions on the bucket. There are two ways to grant the appropriate permissions using the request headers.

You can use either a canned ACL or specify access permissions explicitly. You cannot do both.

The following operations are related to CreateBucket:

#delete(options = {}) ⇒ Struct

Deletes the S3 bucket. All objects (including all object versions and delete markers) in the bucket must be deleted before the bucket itself can be deleted.

Related Resources

#delete!(options = { }) ⇒ void

This method returns an undefined value.

Deletes all objects and versioned objects from this bucket and then deletes the bucket.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb', line 34

def delete! options = { }
  options = {
    initial_wait: 1.3,
    max_attempts: 3,
  }.merge(options)

  attempts = 0
  begin
    clear!
    delete
  rescue Errors::BucketNotEmpty
    attempts += 1
    if attempts >= options[:max_attempts]
      raise
    else
      Kernel.sleep(options[:initial_wait] ** attempts)
      retry
    end
  end
end
#delete_objects(options = {}) ⇒ Types::DeleteObjectsOutput

This operation enables you to delete multiple objects from a bucket using a single HTTP request. If you know the object keys that you want to delete, then this operation provides a suitable alternative to sending individual delete requests, reducing per-request overhead.

The request contains a list of up to 1000 keys that you want to delete. In the XML, you provide the object key names, and optionally, version IDs if you want to delete a specific version of the object from a versioning-enabled bucket. For each key, Amazon S3 performs a delete operation and returns the result of that delete, success, or failure, in the response. Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.

The operation supports two modes for the response: verbose and quiet. By default, the operation uses verbose mode in which the response includes the result of deletion of each key in your request. In quiet mode the response includes only keys where the delete operation encountered an error. For a successful deletion, the operation does not return any information about the delete in the response body.

When performing this operation on an MFA Delete enabled bucket, that attempts to delete any versioned objects, you must include an MFA token. If you do not provide one, the entire request will fail, even if there are non-versioned objects you are trying to delete. If you provide an invalid token, whether there are versioned keys in the request or not, the entire Multi-Object Delete request will fail. For information about MFA Delete, see MFA Delete.

Finally, the Content-MD5 header is required for all Multi-Object Delete requests. Amazon S3 uses the header value to ensure that your request body has not been altered in transit.

The following operations are related to DeleteObjects:

#exists? ⇒ Boolean

Returns true if this Bucket exists. Returns false otherwise.

#presigned_post(options = {}) ⇒ PresignedPost Note:

You must specify :key or :key_starts_with. All other options are optional.

Creates a PresignedPost that makes it easy to upload a file from a web browser direct to Amazon S3 using an HTML post form with a file field.

See the PresignedPost documentation for more information.

91
92
93
94
95
96
97
98
# File 'aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb', line 91

def presigned_post(options = {})
  PresignedPost.new(
    client.config.credentials,
    client.config.region,
    name,
    {url: url}.merge(options)
  )
end
#put_object(options = {}) ⇒ Object #url(options = {}) ⇒ String

Returns a public URL for this bucket.

bucket = s3.bucket('bucket-name')
bucket.url

You can pass virtual_host: true to use the bucket name as the host name.

bucket = s3.bucket('my.bucket.com', virtual_host: true)
bucket.url
73
74
75
76
77
78
79
# File 'aws-sdk-resources/lib/aws-sdk-resources/services/s3/bucket.rb', line 73

def url(options = {})
  if options[:virtual_host]
    "http://#{name}"
  else
    s3_bucket_url
  end
end
#wait_until_exists {|waiter| ... } ⇒ Bucket

Waits until this Bucket is exists. This method waits by polling Client#head_bucket until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default #delay 5 #max_attempts 20

You can modify defaults and register callbacks by passing a block argument.

#wait_until_not_exists {|waiter| ... } ⇒ Bucket

Waits until this Bucket is not_exists. This method waits by polling Client#head_bucket until successful. An error is raised after a configurable number of failed checks.

This waiter uses the following defaults:

Configuration Default #delay 5 #max_attempts 20

You can modify defaults and register callbacks by passing a block argument.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4