3.7 KiB
Page through large lists of containers or objects
If you have a large number of containers or objects, you can use the
marker, limit, and end_marker
parameters to control how many items are returned in a list and where
the list starts or ends. If you want to page backwards you can use the
reverse parameter.
- marker
-
When you request a list of containers or objects, Object Storage returns a maximum of 10,000 names for each request. To get subsequent names, you must make another request with the
markerparameter. Set themarkerparameter to the name of the last item returned in the previous list. You must URL-encode themarkervalue before you send the HTTP request. Object Storage returns a maximum of 10,000 names starting after the last item returned.
- limit
-
To return fewer than 10,000 names, use the
limitparameter. If the number of names returned equals the specifiedlimit(or 10,000 if you omit thelimitparameter), you can assume there are more names to list. If the number of names in the list is exactly divisible by thelimitvalue, the last request has no content.
- end_marker
-
Limits the result set to names that are less than the
end_markerparameter value. You must URL-encode theend_markervalue before you send the HTTP request.
- reverse
-
By default, listings are returned sorted by name, ascending. If you include the
reverse=truequery parameter, the listing will be returned sorted by name, descending.
To page through a large list of containers
Assume the following list of container names:
apples
bananas
kiwis
oranges
pears
Use a
limitof two:# curl -i $publicURL/?limit=2 -X GET -H "X-Auth-Token: $token"apples bananasBecause two container names are returned, there are more names to list.
Make another request with a
markerparameter set to the name of the last item returned:# curl -i $publicURL/?limit=2&marker=bananas -X GET -H \ “X-Auth-Token: $token"kiwis orangesAgain, two items are returned, and there might be more.
Make another request with a
markerof the last item returned:# curl -i $publicURL/?limit=2&marker=oranges -X GET -H \" X-Auth-Token: $token"pearsYou receive a one-item response, which is fewer than the
limitnumber of names. This indicates that this is the end of the list.Use the
end_markerparameter to limit the result set to object names that are less than theend_markerparameter value:# curl -i $publicURL/?end_marker=oranges -X GET -H \" X-Auth-Token: $token"apples bananas kiwisYou receive a result set of all container names before the
end-markervalue.Use the
reverseparameter to work from the back of the list:# curl -i $publicURL/?reverse=true -X GET -H \" X-Auth-Token: $token"pears oranges kiwis bananas applesYou can also combine parameters:
# curl -i $publicURL/?reverse=true&end_marker=kiwis -X GET -H \" X-Auth-Token: $token"pears oranges