Chapter 6. Pseudo hierarchical folders and directories

Although you cannot nest directories in Cloud Files, you can simulate a hierarchical structure within a single container by adding forward slash characters (/) in the object name. To navigate the pseudo directory structure, you can use the delimiter query parameter. For an illustration, see the examples in this section.

[Note]Note

In the examples, the objects reside in a container called backups. Within that container, the objects are organized in a pseudo directory called photos. Remember that the container name is not displayed in the example, but that it is a part of the object URIs. For example, the URI of the file me.jpg is https://storage.clouddrive.com/v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups/photos/me.jpg.

To display a list of all the objects in the storage container, use a GET operation without a delimiter or prefix parameter.

GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups

The system returns status code 200 OK and the requested list of objects.

photos/animals/cats/persian.jpg
photos/animals/cats/siamese.jpg
photos/animals/dogs/corgi.jpg
photos/animals/dogs/poodle.jpg
photos/animals/dogs/terrier.jpg
photos/me.jpg
photos/plants/fern.jpg
photos/plants/rose.jpg

To limit the displayed results, use the delimiter parameter defined as a forward slash (/), as shown in the following example.

GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups?delimiter=/

The system returns status code 200 (OK) and the requested matching objects. Because the request used the slash, only the pseudo directory photos/ is displayed, as shown in the following example. Remember that the returned values from a delimiter query that uses a slash are not real objects. They have a Content-Type of application/directory and are in a subdir section of the JSON and XML results.

photos/

To view the objects inside a pseudo directory, including further nested pseudo directories, use the prefix parameter with the delimiter parameter.

GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups?prefix=photos/&delimiter=/

The system returns status code 200 (OK) and the objects and pseudo directories within the top-level pseudo directory, as shown in the following example.

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

There is no limit to the number of nested pseudo directories you can create. To navigate through them, use a longer prefix parameter coupled with the delimiter parameter. In the following example, the pseudo directory animals contains a pseudo directory called dogs. To navigate directly to the files contained within dogs, enter the command following.

GET /v1/MossoCloudFS_0672d7fa-9f85-4a81-a3ab-adb66a880123/backups?prefix=photos/animals/dogs/&delimiter=/

The system returns status code 200 (OK) and the following objects and pseudo directories within the nested pseudo directory.

photos/animals/dogs/corgi.jpg
photos/animals/dogs/poodle.jpg
photos/animals/dogs/terrier.jpg


loading table of contents...