Agricultue Media Publishing | Page 2

[REST WITH AMAZON’S S3] Date: Tue, 08 August 2008 Amazon AWS 12:00:00 +0000 The web server will return a representation of the resource http://www.amazon.com/myresource.jpg. Likely, there is only one representation; in this case: a jpeg image. However, there can be many representations of a single resource, and the acceptheader can be used to determine which one to return. Assuming proper authorization, that same resource could be deleted using the Delete HTTP method. DELETE /myresource.jpg HTTP/1.1 Host: www.amazon.com Date: Tue, 08 August 2008 12:00:00 +0000 Authorization: [some authorization data] PUT or POST could be used, depending on the implementation, to change the image itself. Amazon’s S3 (Simple Storage Service) is a web service for storing data of any size in buckets. This storage schema is similar to files and folders, except that buckets may not contain other buckets, and the data contained within an S3 object doesn’t need to be typical file-like material (though it often is.) Amazon offers developers a REST interface as a way to access and interact with S3. It also offers a SOAP interface. The REST interface uses the standard HTTP verbs in the manner outlined in this document: GET to retrieve a document or bucket, DELETE to delete the same, etc. Amazon has also released code toolkits in a variety of languages that wrap the REST operations in language-familiar syntax, such as Java classes. For instance, using Amazon’s S3 code to create a bucket: AWSAuthConnection conn = new AWSAuthConnection( accessKeyId, secretAccessKey, false, Utils.DEFAULT_HOST, Utils.INSECURE_PORT, CallingFormat.getPathCallingFormat()); Response createResponse = conn.createBucket(“MyBucke t”, null, null); This will result in a PUT request to Amazon’s S3 server. Deleting (which corresponds to a DELETE HTTP request) the bucket is just as easy: Response deleteResponse = conn.deleteBucket(“MyBucket”, null); Note: To delete a bucket, the bucket must be empty. Also, the above code listing assumes the same AWSAuthConnection object is not null. Creating an object inside a bucket is also a simple set of code. Essentially, you upload a file. This will result in a PUT HTTP request (POST can also be used.) Page 2 of 3