FSI Server OpenAPI – Part IV: Managing Directories.

The previous parts of this series of blog entries showed how to log in to the FSI Server and uploading images with a client application using the OpenAPI. This episode will show how to handle directories, something that is in fact essential before even starting to upload images.

The top-level directories are created by adding an import profile of the desired name. This is not an image management task but an administrative task and can therefore not be performed via the OpenAPI. Please refer to the FSI Server manual to learn how to create an import profile.

Once the import profile is created the directories within this import profile can be managed via the OpenAPI by sending HTTP PUT, POST and DELETE requests to the directory service URI:


In this URI the import profile would be called “path” and “to” and “dir” would be subdirectories in the import profile. Directories are created using PUT requests. Presuming the login process was implemented similar to the one described in part II, the Java code is quite simple:

WebResource directoryResource = client.resource(serviceURL + "directory/path/to/dir");
ActionResponse response = directoryResource.put(ActionResponse.class);

The response will contain a status code and in case of failure also an error description. Deleting a directory is more or less the same but is implemented using a DELETE request instead of a PUT request. Developers implementing client applications using this interface should keep in mind, that this will recursively delete the given directory including all files in subdirectories without requiring any further confirmation. Asking the user if he really wants to delete this directory needs to be implemented in the client application.

Moving or renaming directories is also quite simple to implement on the client side. Renaming directories is quite a complicated operation on the serverside though. This is due to the fact that a rename operation recursively renames all subdirectories including their files inside FSI Servers internal storage. A rename request for a directory containing a lot of files and subdirectories will therefore take accordingly long. Client application developers should make sure that these requests do not time out too quickly.

The rename or move request is a POST request to the source directory URI with a form parameters called “to” which contains the target directory as the value. The following example shows the Java code which moves /path/to/source/dir to /path/to/target/dir:

WebResource sourceDirectoryResource = client.resource(serviceURL + "service/directory/path/to/source/dir");
Form form = new Form();
form.add("to", "path/to/target/dir"); ActionResponse reponse = sourceDirectoryResource.post(ActionResponse.class, form);

Finally the directory URIs support GET requests. These will deliver an XML or JSON formatted list showing the directory contents, enabling developers to write applications to browse through the directory tree on the server.

The next part of this blog series will show how to rename, move and delete images on the server and conclude the series with some final thoughts.