This scenario assumes that the clients want to grab some objects on OpenStack’s Swift via the RESTful request. The main concern is we don’t want to public our container or create Temporary URL every access. As shown in the figure above, the Tomcat instances can verify the access permission or wrap some information before return to the client.
In addition, our GET method didn’t indicate @Produces annotation to specify the MIME media types of representations a resource can produce and send back to the client. The following code snippet use the java-cloudfiles to communicate with the Swift service. First, we obtain the meta-data of the object to get the MIME type, then we store the object content into byte-array as return entity. In the end, we can return the content of a object with corresponding MIME type to the client.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20