lib/cloudfiles/container.rb in cloudfiles-1.4.8 vs lib/cloudfiles/container.rb in cloudfiles-1.4.9

- old
+ new

@@ -116,27 +116,28 @@ alias :get_object :object # Gathers a list of all available objects in the current container and returns an array of object names. # container = cf.container("My Container") - # container.objects #=> [ "dog", "cat", "donkey", "monkeydir/capuchin"] + # container.objects #=> [ "cat", "dog", "donkey", "monkeydir", "monkeydir/capuchin"] # Pass a limit argument to limit the list to a number of objects: - # container.objects(:limit => 1) #=> [ "dog" ] - # Pass an offset with or without a limit to start the list at a certain object: - # container.objects(:limit => 1, :offset => 2) #=> [ "donkey" ] + # container.objects(:limit => 1) #=> [ "cat" ] + # Pass an marker with or without a limit to start the list at a certain object: + # container.objects(:limit => 1, :marker => 'dog') #=> [ "donkey" ] # Pass a prefix to search for objects that start with a certain string: # container.objects(:prefix => "do") #=> [ "dog", "donkey" ] # Only search within a certain pseudo-filesystem path: # container.objects(:path => 'monkeydir') #=> ["monkeydir/capuchin"] # All arguments to this method are optional. # # Returns an empty array if no object exist in the container. Throws an InvalidResponseException # if the request fails. def objects(params = {}) + params[:marker] ||= params[:offset] paramarr = [] paramarr << ["limit=#{URI.encode(params[:limit].to_s).gsub(/&/,'%26')}"] if params[:limit] - paramarr << ["offset=#{URI.encode(params[:offset].to_s).gsub(/&/,'%26')}"] if params[:offset] + paramarr << ["marker=#{URI.encode(params[:marker].to_s).gsub(/&/,'%26')}"] if params[:marker] paramarr << ["prefix=#{URI.encode(params[:prefix]).gsub(/&/,'%26')}"] if params[:prefix] paramarr << ["path=#{URI.encode(params[:path]).gsub(/&/,'%26')}"] if params[:path] paramstr = (paramarr.size > 0)? paramarr.join("&") : "" ; response = self.connection.cfreq("GET",@storagehost,"#{@storagepath}?#{paramstr}",@storageport,@storagescheme) return [] if (response.code == "204") @@ -160,13 +161,14 @@ # :hash=>"0aa820d91aed05d2ef291d324e47bc96", # :last_modified=>Wed Jan 28 10:16:26 -0600 2009, # :bytes=>"22"} # } def objects_detail(params = {}) + params[:marker] ||= params[:offset] paramarr = [] paramarr << ["format=xml"] paramarr << ["limit=#{URI.encode(params[:limit].to_s).gsub(/&/,'%26')}"] if params[:limit] - paramarr << ["offset=#{URI.encode(params[:offset].to_s).gsub(/&/,'%26')}"] if params[:offset] + paramarr << ["marker=#{URI.encode(params[:marker].to_s).gsub(/&/,'%26')}"] if params[:marker] paramarr << ["prefix=#{URI.encode(params[:prefix]).gsub(/&/,'%26')}"] if params[:prefix] paramarr << ["path=#{URI.encode(params[:path]).gsub(/&/,'%26')}"] if params[:path] paramstr = (paramarr.size > 0)? paramarr.join("&") : "" ; response = self.connection.cfreq("GET",@storagehost,"#{@storagepath}?#{paramstr}",@storageport,@storagescheme) return {} if (response.code == "204")