Table of Contents

Interface ITransferUtility

Namespace
Amazon.S3.Transfer
Assembly
AWSSDK.S3.dll

Provides a high level utility for managing transfers to and from Amazon S3.

TransferUtility provides a simple API for uploading content to and downloading content from Amazon S3. It makes extensive use of Amazon S3 multipart uploads to achieve enhanced throughput, performance, and reliability.

When uploading large files by specifying file paths instead of a stream, TransferUtility uses multiple threads to upload multiple parts of a single upload at once. When dealing with large content sizes and high bandwidth, this can increase throughput significantly.

public interface ITransferUtility : IDisposable
Inherited Members

Remarks

Transfers are stored in memory. If the application is restarted, previous transfers are no longer accessible. In this situation, if necessary, you should clean up any multipart uploads that are incomplete.

Properties

S3Client

Gets the Amazon S3 client used for making calls into Amazon S3.

IAmazonS3 S3Client { get; }

Property Value

IAmazonS3

The Amazon S3 client used for making calls into Amazon S3.

Methods

AbortMultipartUploads(string, DateTime)

Aborts the multipart uploads that were initiated before the specified date.

void AbortMultipartUploads(string bucketName, DateTime initiatedDate)

Parameters

bucketName string

The name of the bucket containing multipart uploads.

initiatedDate DateTime

The date before which the multipart uploads were initiated.

AbortMultipartUploadsAsync(string, DateTime, CancellationToken)

Aborts the multipart uploads that were initiated before the specified date.

Task AbortMultipartUploadsAsync(string bucketName, DateTime initiatedDate, CancellationToken cancellationToken = default)

Parameters

bucketName string

The name of the bucket containing multipart uploads.

initiatedDate DateTime

The date before which the multipart uploads were initiated.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Download(TransferUtilityDownloadRequest)

Downloads the content from Amazon S3 and writes it to the specified file.
If the key is not specified in the request parameter, the file name will used as the key name.

void Download(TransferUtilityDownloadRequest request)

Parameters

request TransferUtilityDownloadRequest

Contains all the parameters required to download an Amazon S3 object.

Download(string, string, string)

Downloads the content from Amazon S3 and writes it to the specified file.

void Download(string filePath, string bucketName, string key)

Parameters

filePath string

The file path where the content from Amazon S3 will be written to.

bucketName string

The name of the bucket containing the Amazon S3 object to download.

key string

The key under which the Amazon S3 object is stored.

DownloadAsync(TransferUtilityDownloadRequest, CancellationToken)

Downloads the content from Amazon S3 and writes it to the specified file.
If the key is not specified in the request parameter, the file name will used as the key name.

Task DownloadAsync(TransferUtilityDownloadRequest request, CancellationToken cancellationToken = default)

Parameters

request TransferUtilityDownloadRequest

Contains all the parameters required to download an Amazon S3 object.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

DownloadAsync(string, string, string, CancellationToken)

Downloads the content from Amazon S3 and writes it to the specified file.

Task DownloadAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default)

Parameters

filePath string

The file path where the content from Amazon S3 will be written to.

bucketName string

The name of the bucket containing the Amazon S3 object to download.

key string

The key under which the Amazon S3 object is stored.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

DownloadDirectory(TransferUtilityDownloadDirectoryRequest)

Downloads the objects in Amazon S3 that have a key that starts with the value specified by the S3Directory property of the passed in TransferUtilityDownloadDirectoryRequest object.

void DownloadDirectory(TransferUtilityDownloadDirectoryRequest request)

Parameters

request TransferUtilityDownloadDirectoryRequest

Contains all the parameters required to download objects from Amazon S3 into a local directory.

DownloadDirectory(string, string, string)

Downloads the objects in Amazon S3 that have a key that starts with the value specified by s3Directory.

void DownloadDirectory(string bucketName, string s3Directory, string localDirectory)

Parameters

bucketName string

The name of the bucket containing the Amazon S3 objects to download.

s3Directory string

The directory in Amazon S3 to download.

localDirectory string

The local directory to download the objects to.

DownloadDirectoryAsync(TransferUtilityDownloadDirectoryRequest, CancellationToken)

Downloads the objects in Amazon S3 that have a key that starts with the value specified by the S3Directory property of the passed in TransferUtilityDownloadDirectoryRequest object.

Task DownloadDirectoryAsync(TransferUtilityDownloadDirectoryRequest request, CancellationToken cancellationToken = default)

Parameters

request TransferUtilityDownloadDirectoryRequest

Contains all the parameters required to download objects from Amazon S3 into a local directory.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

DownloadDirectoryAsync(string, string, string, CancellationToken)

Downloads the objects in Amazon S3 that have a key that starts with the value specified by s3Directory.

Task DownloadDirectoryAsync(string bucketName, string s3Directory, string localDirectory, CancellationToken cancellationToken = default)

Parameters

bucketName string

The name of the bucket containing the Amazon S3 objects to download.

s3Directory string

The directory in Amazon S3 to download.

localDirectory string

The local directory to download the objects to.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

OpenStream(TransferUtilityOpenStreamRequest)

Returns a stream to read the contents from Amazon S3 as specified by the TransferUtilityOpenStreamRequest. The caller of this method is responsible for closing the stream.

Stream OpenStream(TransferUtilityOpenStreamRequest request)

Parameters

request TransferUtilityOpenStreamRequest

Contains all the parameters required to open a stream to an S3 object.

Returns

Stream

A stream of the contents from Amazon S3.

OpenStream(string, string)

Returns a stream from which the caller can read the content from the specified Amazon S3 bucket and key. The caller of this method is responsible for closing the stream.

Stream OpenStream(string bucketName, string key)

Parameters

bucketName string

The name of the bucket.

key string

The object key.

Returns

Stream

A stream of the contents from the specified Amazon S3 and key.

OpenStreamAsync(TransferUtilityOpenStreamRequest, CancellationToken)

Returns a stream to read the contents from Amazon S3 as specified by the TransferUtilityOpenStreamRequest. The caller of this method is responsible for closing the stream.

Task<Stream> OpenStreamAsync(TransferUtilityOpenStreamRequest request, CancellationToken cancellationToken = default)

Parameters

request TransferUtilityOpenStreamRequest

Contains all the parameters required for the OpenStream operation.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task<Stream>

The task object representing the asynchronous operation.

OpenStreamAsync(string, string, CancellationToken)

Returns a stream from which the caller can read the content from the specified Amazon S3 bucket and key. The caller of this method is responsible for closing the stream.

Task<Stream> OpenStreamAsync(string bucketName, string key, CancellationToken cancellationToken = default)

Parameters

bucketName string

The name of the bucket.

key string

The object key.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task<Stream>

The task object representing the asynchronous operation.

Upload(TransferUtilityUploadRequest)

Uploads the file or stream specified by the request.
To track the progress of the upload, add an event listener to the request's UploadProgressEvent. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void Upload(TransferUtilityUploadRequest request)

Parameters

request TransferUtilityUploadRequest

Contains all the parameters required to upload to Amazon S3.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

Upload(Stream, string, string)

Uploads the contents of the specified stream.
For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void Upload(Stream stream, string bucketName, string key)

Parameters

stream Stream

The stream to read to obtain the content to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.

key string

The key under which the Amazon S3 object is stored.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

Upload(string, string)

Uploads the specified file.
The object key is derived from the file's name. Multiple threads are used to read the file and perform multiple uploads in parallel.
For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void Upload(string filePath, string bucketName)

Parameters

filePath string

The file path of the file to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

Upload(string, string, string)

Uploads the specified file.
Multiple threads are used to read the file and perform multiple uploads in parallel.
For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void Upload(string filePath, string bucketName, string key)

Parameters

filePath string

The file path of the file to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.

key string

The key under which the Amazon S3 object is stored.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

UploadAsync(TransferUtilityUploadRequest, CancellationToken)

Uploads the file or stream specified by the request.
To track the progress of the upload, add an event listener to the request's UploadProgressEvent. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default)

Parameters

request TransferUtilityUploadRequest

Contains all the parameters required to upload to Amazon S3.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.

UploadAsync(Stream, string, string, CancellationToken)

Uploads the contents of the specified stream.
For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadAsync(Stream stream, string bucketName, string key, CancellationToken cancellationToken = default)

Parameters

stream Stream

The stream to read to obtain the content to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.

key string

The key under which the Amazon S3 object is stored.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.

UploadAsync(string, string, string, CancellationToken)

Uploads the specified file.
Multiple threads are used to read the file and perform multiple uploads in parallel.
For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default)

Parameters

filePath string

The file path of the file to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.

key string

The key under which the Amazon S3 object is stored.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.

UploadAsync(string, string, CancellationToken)

Uploads the specified file.
The object key is derived from the file's name. Multiple threads are used to read the file and perform multiple uploads in parallel.
For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadAsync(string filePath, string bucketName, CancellationToken cancellationToken = default)

Parameters

filePath string

The file path of the file to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the file to.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploadsAsync() to abort the incomplete multipart uploads.

UploadDirectory(TransferUtilityUploadDirectoryRequest)

Uploads files from a specified directory.
The object key is derived from the file names inside the directory. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void UploadDirectory(TransferUtilityUploadDirectoryRequest request)

Parameters

request TransferUtilityUploadDirectoryRequest

The request that contains all the parameters required to upload a directory.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

UploadDirectory(string, string)

Uploads files from a specified directory.
The object key is derived from the file names inside the directory. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void UploadDirectory(string directory, string bucketName)

Parameters

directory string

The source directory, that is, the directory containing the files to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

UploadDirectory(string, string, string, SearchOption)

Uploads files from a specified directory.
The object key is derived from the file names inside the directory. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

void UploadDirectory(string directory, string bucketName, string searchPattern, SearchOption searchOption)

Parameters

directory string

The source directory, that is, the directory containing the files to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.

searchPattern string

A pattern used to identify the files from the source directory to upload.

searchOption SearchOption

A search option that specifies whether to recursively search for files to upload in subdirectories.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

UploadDirectoryAsync(TransferUtilityUploadDirectoryRequest, CancellationToken)

Uploads files from a specified directory.
The object key is derived from the file names inside the directory. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadDirectoryAsync(TransferUtilityUploadDirectoryRequest request, CancellationToken cancellationToken = default)

Parameters

request TransferUtilityUploadDirectoryRequest

The request that contains all the parameters required to upload a directory.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

UploadDirectoryAsync(string, string, string, SearchOption, CancellationToken)

Uploads files from a specified directory.
The object key is derived from the file names inside the directory. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadDirectoryAsync(string directory, string bucketName, string searchPattern, SearchOption searchOption, CancellationToken cancellationToken = default)

Parameters

directory string

The source directory, that is, the directory containing the files to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.

searchPattern string

A pattern used to identify the files from the source directory to upload.

searchOption SearchOption

A search option that specifies whether to recursively search for files to upload in subdirectories.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.

UploadDirectoryAsync(string, string, CancellationToken)

Uploads files from a specified directory.
The object key is derived from the file names inside the directory. For large uploads, the file will be divided and uploaded in parts using Amazon S3's multipart API. The parts will be reassembled as one object in Amazon S3.

Task UploadDirectoryAsync(string directory, string bucketName, CancellationToken cancellationToken = default)

Parameters

directory string

The source directory, that is, the directory containing the files to upload.

bucketName string

The target Amazon S3 bucket, that is, the name of the bucket to upload the files to.

cancellationToken CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

Task

The task object representing the asynchronous operation.

Remarks

If you are uploading large files, TransferUtility will use multipart upload to fulfill the request. If a multipart upload is interrupted, TransferUtility will attempt to abort the multipart upload. Under certain circumstances (network outage, power failure, etc.), TransferUtility will not be able to abort the multipart upload. In this case, in order to stop getting charged for the storage of uploaded parts, you should manually invoke TransferUtility.AbortMultipartUploads() to abort the incomplete multipart uploads.