Class | S33r::S3Object |
In: |
lib/s33r/bucket_listing.rb
|
Parent: | Object |
Representation of an object stored in a bucket.
etag | [R] | |
key | [R] | |
last_modified | [R] | |
named_bucket | [R] | |
named_bucket | [W] | |
owner | [R] | |
size | [R] | |
storage_class | [R] |
Create from a node.
# File lib/s33r/bucket_listing.rb, line 105 105: def initialize(node=nil, named_bucket=nil) 106: @named_bucket = named_bucket 107: self.set_from_node(node) unless node.nil? 108: end
Remove this object from associated NamedBucket.
# File lib/s33r/bucket_listing.rb, line 111 111: def delete 112: @named_bucket.delete_key(@key) unless @named_bucket.nil? 113: end
Set properties of the object from an XML document.
doc: XML::Document instance to parse to get properties for this object.
# File lib/s33r/bucket_listing.rb, line 126 126: def set_from_node(doc) 127: @key = doc.xget('Key') 128: @last_modified = DateTime.parse(doc.xget('LastModified')) 129: @etag = doc.xget('ETag').gsub("\"", "") 130: @size = doc.xget('Size').to_i 131: @owner = S3User.new(doc.find('Owner').to_a.first) 132: 133: # TODO: if setting from a full object listing (GET on a resource key), 134: # do additional field setting here (e.g. x-amz-meta- headers) 135: # and assign the response body to some data field; detect whether 136: # these fields exist before attempting to set properties 137: end