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 112 112: def initialize(node=nil, named_bucket=nil) 113: @named_bucket = named_bucket 114: self.set_from_node(node) unless node.nil? 115: end
Remove this object from associated NamedBucket.
# File lib/s33r/bucket_listing.rb, line 118 118: def delete 119: @named_bucket.delete_key(@key) unless @named_bucket.nil? 120: 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 133 133: def set_from_node(doc) 134: @key = doc.xget('Key') 135: @last_modified = DateTime.parse(doc.xget('LastModified')) 136: @etag = doc.xget('ETag').gsub("\"", "") 137: @size = doc.xget('Size').to_i 138: 139: # Build representation of the owner. 140: user_xml_doc = doc.find('Owner').to_a.first 141: @owner = S3ACL::CanonicalUser.from_xml(user_xml_doc) 142: 143: # TODO: if setting from a full object listing (GET on a resource key), 144: # do additional field setting here (e.g. x-amz-meta- headers) 145: # and assign the response body to some data field; detect whether 146: # these fields exist before attempting to set properties 147: end