Class: Aws::S3::Resource
- Inherits:
-
Object
- Object
- Aws::S3::Resource
- Defined in:
- 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
182 183 184 185 186 187 |
# File 'lib/aws-sdk-s3/resource.rb', line 182 def bucket(name) Bucket.new( name: name, client: @client ) end |
#buckets(options = {}) ⇒ Bucket::Collection
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/aws-sdk-s3/resource.rb', line 194 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 |