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.
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.
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
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.
When using a stream for the source of data, the
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
TransferUtilityclass that enables you to specify a file, directory, or stream for uploading your data. It also includes the
TransferUtilityUploadDirectoryRequestclasses 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
InitiateMultipartUploadResponseclasses you can use when initiating a multipart upload, and the
UploadPartResponseclasses 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.
The examples in this guide are AWS SDK for .NET version 2.0 compliant.
General Process of Creating .NET Code Examples
Create a credentials profile for your AWS credentials as described in the AWS SDK for .NET topic Configuring AWS Credentials.
Create a new Visual Studio project using the AWS Empty Project template.
Replace the code in the project file,
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/.