简体   繁体   中英

How to list objects and (virtual directorys) using the REST API for OpenStack Object Store(Swift)

we use the REST API for OpenStack Object Store(Swift). guessing the following structure does exist in the OpenStack Object Store:

/containername/object1.txt
/containername/object2.txt
/containername/pseudo-directoryname/object3.txt
/containername/pseudo-directoryname/object4.txt

To get a list of objects from a container we can use a HTTP GET request with the specified URL. So far so good. Result:

/object1
/object2.txt
/pseudo-directoryname/object3
/pseudo-directoryname/object4.txt

The GET request combined with a delimiter parameter ("URL+ABSOLUTEPATH?delimiter=/") cuts the pseudo directories from the result.

/object1.txt
/object2.txt

I would like to have a list of all objects within the container combined with the pseudo directories within the container.

Is there a solution to get the following result without getting all objects and parse them on client side?

 /object1.txt
 /object2.txt
 /pseudo-directoryname/

I didn't find anything about wildcards when using the delimiter parameter. Something like "URL+ABSOLUTEPATH?delimiter=/*/".

I was just trying to work the same thing out. Found the answer in the docs: http://docs.openstack.org/user-guide/cli_swift_pseudo_hierarchical_folders_directories.html#list-pseudo-hierarchical-folders-request-http

Using their example (note the prefix and delimiter query string parameters):

$ curl -X GET -i -H "X-Auth-Token: $token" $publicurl/v1/AccountString/backups?prefix=photos/&delimiter=/

Would return:

photos/animals/
photos/me.jpg
photos/plants/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM