Class: Aws::S3::Resource
- Inherits:
-
Object
- Object
- Aws::S3::Resource
- Defined in:
- gems/aws-sdk-s3/lib/aws-sdk-s3/resource.rb
Overview
This class provides a resource oriented interface for S3. To create a resource object:
resource = Aws::S3::Resource.new(region: 'us-west-2')
You can supply a client object with custom configuration that will be used for all resource operations.
If you do not pass :client
, a default client will be constructed.
client = Aws::S3::Client.new(region: 'us-west-2')
resource = Aws::S3::Resource.new(client: client)
Actions collapse
Associations collapse
Instance Method Summary collapse
-
#client ⇒ Client
-
#initialize(options = {}) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
Instance Method Details
#bucket(name) ⇒ Bucket
183 184 185 186 187 188 |
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/resource.rb', line 183 def bucket(name) Bucket.new( name: name, client: @client ) end |
#buckets(options = {}) ⇒ Bucket::Collection
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/resource.rb', line 219 def buckets( = {}) batches = Enumerator.new do |y| resp = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do @client.list_buckets() end resp.each_page do |page| batch = [] page.data.buckets.each do |b| batch << Bucket.new( name: b.name, data: b, client: @client ) end y.yield(batch) end end Bucket::Collection.new(batches) end |
#client ⇒ Client
32 33 34 |
# File 'gems/aws-sdk-s3/lib/aws-sdk-s3/resource.rb', line 32 def client @client end |