Getting Started with Amazon S3
To get started using Amazon S3, you must first create an Amazon Web services account
. You'll need to provide some minimal personal information to create the account. If you already have an Amazon.com account (an account you use to make purchases from Amazon.com), you can simply login to your existing account.
After logging in, you must enable the S3 service for your account. Navigate to http://aws.amazon.com/S3
and click the Amazon S3 link in the left panel. That will take you to a page where you should see and click the "Sign Up for Web service" graphic link (see Figure 1
If you haven't already provided a credit card for normal Amazon billing, you will be asked to do so at this time. After enabling the S3 service for your account, you can click "View Access Key Identifiers" link to view your Access Key ID and Secret Access Key (see Figure 2). You'll see a screen that displays your Access Key ID and your Secret Access Key as shown in Figure 3.
|Figure 2. Getting S3 Authorization: Click the "View Access Key Identifiers" link to obtain your Access Key ID and your Secret Access Key.||
|Figure 3. Authentication Keys: The figure shows a sample of how your S3 Access Key ID and Secret Access Key look.||
At this point your account is configured properly to use S3.
The Sample Application
|Figure 4. Change your Access Key ID and your Secret Access Key in the project settings before attempting to run the sample application.|
Before attempting to run the sample code
, you must first modify the project's application settings to update your Access Key ID and Secret Access Key. Using Visual Studio 2005, there are two ways to change the settings. First, you can right-click the project name and select Properties. Then select the Settings tab, and modify the settings appropriately. See Figure 4
The second method of modifying the identifiers is to modify the values directly in the app.config
file. Now you're ready to test the application.
To exercise the functionality of the sample application, enter a bucket name and click the "Create Bucket" button. The list of buckets should automatically refresh and should now include the name of the bucket you just entered. Click the "View Contents" link for the bucket you just created, and verify that there are no objects listed in the bucket. Now create several sample objects in the bucket. Your sample application should look similar to the example shown in Figure 5.
|Figure 5. Sample Application: The figure shows how the sample application looks after creating a bucket and adding several sample objects.||
|Figure 6. Viewing Object Data: This dialog shows details about the data contained in a selected object.||
Click the "View Object Data" link for one of the sample objects you created. A dialog will appear showing the data contained in the selected objectsee Figure 6
In addition to displaying the object's name and value, the dialog displays metadata entries associated with the object.
The sample application focuses on the AmazonS3 class, which provides connectivity to the AmazonS3 Web services interface, constructs the required authentication parameters, and calls the specific Web methods.
As described above, each of the AWS method calls includes three parameters used for authentication: the Access Key ID, a timestamp, and the signature. As illustrated in the code, it is important that that timestamp (datetime variable) used in the second authentication parameter be the same timestamp used to generate the signature. Also, when generating the signature, it is important that you use the correct method name to generate the signature.
The primary goal of the sample application provided with this article is to provide a rapid introduction to the Amazon S3 SOAP API. Amazon S3 provides a considerably more extensive set of features for reading and writing objects as well as managing access control to buckets and objects. These features are documented in the Amazon S3 Developer Guide, and I urge you to explore them.