Class | AWS::S3::Service |
In: |
lib/aws/s3/service.rb
|
Parent: | Base |
The service lets you find out general information about your account, like what buckets you have.
Service.buckets # => []
List all your buckets.
Service.buckets # => []
For performance reasons, the bucket list will be cached. If you want avoid all caching, pass the :reload as an argument:
Service.buckets(:reload)
# File lib/aws/s3/service.rb, line 20 20: def buckets 21: response = get('/') 22: if response.empty? 23: [] 24: else 25: response.buckets.map {|attributes| Bucket.new(attributes)} 26: end 27: end
Sometimes methods that make requests to the S3 servers return some object, like a Bucket or an S3Object. Othertimes they return just true. Other times they raise an exception that you may want to rescue. Despite all these possible outcomes, every method that makes a request stores its response object for you in Service.response. You can always get to the last request‘s response via Service.response.
objects = Bucket.objects('jukebox') Service.response.success? # => true
This is also useful when an error exception is raised in the console which you weren‘t expecting. You can root around in the response to get more details of what might have gone wrong.
# File lib/aws/s3/service.rb, line 41 41: def response 42: @@response 43: end