Method: Backup::CloudIO::S3#objects
- Defined in:
- lib/backup/cloud_io/s3.rb
#objects(prefix) ⇒ Object
Returns all objects in the bucket with the given prefix.
-
#get_bucket returns a max of 1000 objects per request.
-
Returns objects in alphabetical order.
-
If marker is given, only objects after the marker are in the response.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/backup/cloud_io/s3.rb', line 68 def objects(prefix) objects = [] resp = nil prefix = prefix.chomp('/') opts = { 'prefix' => prefix + '/' } while resp.nil? || resp.body['IsTruncated'] opts.merge!('marker' => objects.last.key) unless objects.empty? with_retries("GET '#{ bucket }/#{ prefix }/*'") do resp = connection.get_bucket(bucket, opts) end resp.body['Contents'].each do |obj_data| objects << Object.new(self, obj_data) end end objects end |