Method: CloudFiles::Container#objects_detail
- Defined in:
- lib/vendor/cloudfiles-1.3.0/cloudfiles/container.rb
#objects_detail(params = {}) ⇒ Object Also known as: list_objects_info
Retrieves a list of all objects in the current container along with their size in bytes, hash, and content_type. If no objects exist, an empty hash is returned. Throws an InvalidResponseException if the request fails. Takes a parameter hash as an argument, in the same form as the objects method.
Returns a hash in the same format as the containers_detail from the CloudFiles class.
container.objects_detail
=> {"test.txt"=>{:content_type=>"application/octet-stream",
:hash=>"e2a6fcb4771aa3509f6b27b6a97da55b",
:last_modified=>Mon Jan 19 10:43:36 -0600 2009,
:bytes=>"16"},
"new.txt"=>{:content_type=>"application/octet-stream",
:hash=>"0aa820d91aed05d2ef291d324e47bc96",
:last_modified=>Wed Jan 28 10:16:26 -0600 2009,
:bytes=>"22"}
}
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/vendor/cloudfiles-1.3.0/cloudfiles/container.rb', line 144 def objects_detail(params = {}) paramarr = [] paramarr << ["format=xml"] paramarr << ["limit=#{URI.encode(params[:limit].to_i)}"] if params[:limit] paramarr << ["offset=#{URI.encode(params[:offset].to_i)}"] if params[:offset] paramarr << ["prefix=#{URI.encode(params[:prefix])}"] if params[:prefix] paramarr << ["path=#{URI.encode(params[:path])}"] if params[:path] paramstr = (paramarr.size > 0)? paramarr.join("&") : "" ; response = self.connection.cfreq("GET",@storagehost,"#{@storagepath}?#{paramstr}") return {} if (response.code == "204") raise InvalidResponseException, "Invalid response code #{response.code}" unless (response.code == "200") doc = REXML::Document.new(response.body) detailhash = {} doc.elements.each("container/object") { |o| detailhash[o.elements["name"].text] = { :bytes => o.elements["bytes"].text, :hash => o.elements["hash"].text, :content_type => o.elements["content_type"].text, :last_modified => Time.parse(o.elements["last_modified"].text) } } doc = nil return detailhash end |