RESTful Web Services Developer's Guide

Extending the Storage-Service Example

This example demonstrates storing and returning plain text strings. This example can easily be modified to store and return arbitrary binary data, for example, images. You can easily store any piece of data with any media type. All you have to do is, in the examples in the previous section, change the text/plain parameter to image/jpeg, or some other value, and point to a JPEG file. For example, to create some content that is a JPEG file, you could use the following curl command.

curl -X PUT -HContent-type:image/jpeg --data 
			/home/jersey_logo.jpg  
			http://127.0.0.1:9998/storage/containers/images/1

To retrieve the contents of the item containing the image, use the following command:

curl  http://127.0.0.1:9998/storage/containers/images/1