Class: Fog::AWS::S3::Directories
- Inherits:
-
Collection
- Object
- Array
- Collection
- Fog::AWS::S3::Directories
- Defined in:
- lib/fog/aws/models/s3/directories.rb
Instance Method Summary collapse
Methods inherited from Collection
#_dump, _load, aliases, attribute, attributes, #attributes, #connection, #connection=, #create, #initialize, #inspect, #load, #merge_attributes, #model, model, #new, #reload, #table, #to_json
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all ⇒ Object
24 25 26 27 |
# File 'lib/fog/aws/models/s3/directories.rb', line 24 def all data = connection.get_service.body['Buckets'] load(data) end |
#get(key, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fog/aws/models/s3/directories.rb', line 29 def get(key, = {}) remap_attributes(, { :delimiter => 'delimiter', :marker => 'marker', :max_keys => 'max-keys', :prefix => 'prefix' }) data = connection.get_bucket(key, ).body directory = new(:key => data['Name']) = {} for key, value in data if ['Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(key) [key] = value end end directory.files.merge_attributes() files = data['Contents'] while data['IsTruncated'] data = connection.get_bucket(key, .merge!('marker' => files.last['Key'])).body files.concat(data['Contents']) end directory.files.load(files) directory rescue Excon::Errors::NotFound nil end |