Menu
Amazon Simple Storage Service
Developer Guide (API Version 2006-03-01)

Using the AWS SDK for .NET

The AWS SDK for .NET provides the API for the Amazon S3 bucket and object operations. For object operations, in addition to providing the API to upload objects in a single operation, the SDK provides the API to upload large objects in parts (see Uploading Objects Using Multipart Upload API). The API gives you the option of using a high-level or low-level API.

Low-Level API

The low-level APIs correspond to the underlying Amazon S3 REST operations, including the create, update, and delete operations that apply to buckets and objects. When you upload large objects using the low-level multipart upload API (see Uploading Objects Using Multipart Upload API) it provides greater control, such as letting you pause and resume multipart uploads, vary part sizes during the upload, or to begin uploads when you do not know the size of the data in advance. If you do not have these requirements, use the high-level API for uploading objects.

High-Level API

For uploading objects, the SDK provides a higher level of abstraction by providing the TransferUtility class. The high-level API is a simpler API, where in just a few lines of code you can upload files and streams to Amazon S3. You should use this API to upload data unless you need to control the upload as described in the preceding Low-Level API section.

For smaller data size the TransferUtility API uploads data in a single operation. However, the TransferUtility switches to using the multipart upload API when data size reaches certain threshold. By default, it uses multiple threads to concurrently upload the parts. If a part upload fails, the API retries the failed part upload up to three times. However, these are configurable options.

Note

When using a stream for the source of data, the TransferUtility class will not do concurrent uploads.

The .NET API Organization

When writing Amazon S3 applications using the AWS SDK for .NET, you use the AWSSDK.dll. The following namespaces in this assembly provide the multipart upload API:

  • Amazon.S3.Transfer—Provides the high-level API to upload your data in parts.

    It includes the TransferUtility class that enables you to specify a file, directory, or stream for uploading your data. It also includes the TransferUtilityUploadRequest and TransferUtilityUploadDirectoryRequest classes to configure advanced settings such as the number of concurrent threads, part size, object metadata, the storage class (STANDARD, REDUCED_REDUNDANCY) and object ACL.

  • Amazon.S3—Provides the implementation for the low-level APIs.

    It provides methods that correspond to the Amazon S3 REST multipart upload API (see Using the REST API for Multipart Upload).

  • Amazon.S3.Model—Provides the low-level API classes to create requests and process responses.

    For example, it provides the InitiateMultipartUploadRequest and InitiateMultipartUploadResponse classes you can use when initiating a multipart upload, and the UploadPartRequest and UploadPartResponse classes when uploading parts.

For more information about the AWS SDK for .NET API, go to AWS SDK for .NET Reference.

Running the Amazon S3 .NET Code Examples

The easiest way to get started with the .NET code examples is to install the AWS SDK for .NET. For more information, go to AWS SDK for .NET.

Note

The examples in this guide are AWS SDK for .NET version 2.0 compliant.

The following tasks guide you through creating and testing the C# code examples provided in this section.

General Process of Creating .NET Code Examples

1

Create a credentials profile for your AWS credentials as described in the AWS SDK for .NET topic Configuring AWS Credentials.

2

Create a new Visual Studio project using the AWS Empty Project template.

3

Replace the code in the project file, Program.cs, with the code in the section you are reading.

4

Run the code. Verify that the object is created using the AWS Management Console. For more information about AWS Management Console, go to https://aws.amazon.com/console/.