Class S33r::S3Object
In: lib/s33r/bucket_listing.rb
Parent: Object

Representation of an object stored in a bucket.

Methods

Attributes

etag  [R] 
key  [R] 
last_modified  [R] 
named_bucket  [R] 
named_bucket  [W] 
owner  [R] 
size  [R] 
storage_class  [R] 

Public Class methods

Create from a node.

[Source]

     # 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

Public Instance methods

Remove this object from associated NamedBucket.

[Source]

     # 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.

[Source]

     # 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

Set properties of the object from an XML string.

xml_str should be a string representing a full XML document, containing a <Contents> element as its root element.

[Source]

     # File lib/s33r/bucket_listing.rb, line 119
119:     def set_from_xml_string(xml_str)
120:       set_from_node(XML.get_xml_doc(xml_str))
121:     end

[Validate]