Class: Aws::S3::Bucket
- Inherits:
-
Object
- Object
- Aws::S3::Bucket
- Defined in:
- lib/aws-sdk-resources/services/s3/bucket.rb
Instance Method Summary collapse
-
#clear! ⇒ void
Deletes all objects and versioned objects from this bucket.
-
#delete! ⇒ void
Deletes all objects and versioned objects from this bucket and then deletes the bucket.
- #load ⇒ Object private
-
#presigned_post(options = {}) ⇒ PresignedPost
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.
-
#url(options = {}) ⇒ String
Returns a public URL for this bucket.
Instance Method Details
#clear! ⇒ void
This method returns an undefined value.
Deletes all objects and versioned objects from this bucket
14 15 16 |
# File 'lib/aws-sdk-resources/services/s3/bucket.rb', line 14 def clear! object_versions.delete end |
#delete! ⇒ void
This method returns an undefined value.
Deletes all objects and versioned objects from this bucket and then deletes the bucket.
26 27 28 29 |
# File 'lib/aws-sdk-resources/services/s3/bucket.rb', line 26 def delete! clear! delete end |
#load ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 80 |
# File 'lib/aws-sdk-resources/services/s3/bucket.rb', line 76 def load @data = client.list_buckets.buckets.find { |b| b.name == name } raise "unable to load bucket #{name}" if @data.nil? self end |
#presigned_post(options = {}) ⇒ PresignedPost
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.
67 68 69 70 71 72 73 |
# File 'lib/aws-sdk-resources/services/s3/bucket.rb', line 67 def presigned_post( = {}) PresignedPost.new( client.config.credentials, client.config.region, name, ) end |
#url(options = {}) ⇒ String
Returns a public URL for this bucket.
bucket = s3.bucket('bucket-name')
bucket.url
#=> "https://bucket-name.s3.amazonaws.com"
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
#=> "http://my.bucket.com"
49 50 51 52 53 54 55 |
# File 'lib/aws-sdk-resources/services/s3/bucket.rb', line 49 def url( = {}) if [:virtual_host] "http://#{name}" else s3_bucket_url end end |