Class TransferUtility
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 class TransferUtility : ITransferUtility, IDisposable
- Inheritance
-
TransferUtility
- Implements
- 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.
Constructors
TransferUtility()
Constructs a new TransferUtility class.
public TransferUtility()
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(RegionEndpoint)
Constructs a new TransferUtility class.
public TransferUtility(RegionEndpoint region)
Parameters
region
RegionEndpointThe region to configure the transfer utility for.
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(IAmazonS3)
Constructs a new instance of the TransferUtility class.
public TransferUtility(IAmazonS3 s3Client)
Parameters
s3Client
IAmazonS3The Amazon S3 client.
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(IAmazonS3, TransferUtilityConfig)
Initializes a new instance of the TransferUtility class.
public TransferUtility(IAmazonS3 s3Client, TransferUtilityConfig config)
Parameters
s3Client
IAmazonS3The Amazon S3 client.
config
TransferUtilityConfigSpecifies advanced configuration settings for TransferUtility.
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(TransferUtilityConfig)
Constructs a new TransferUtility class.
public TransferUtility(TransferUtilityConfig config)
Parameters
config
TransferUtilityConfigSpecifies advanced configuration settings for TransferUtility.
TransferUtility(string, string)
Constructs a new TransferUtility class.
public TransferUtility(string awsAccessKeyId, string awsSecretAccessKey)
Parameters
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(string, string, RegionEndpoint)
Constructs a new TransferUtility class.
public TransferUtility(string awsAccessKeyId, string awsSecretAccessKey, RegionEndpoint region)
Parameters
awsAccessKeyId
stringThe AWS Access Key ID.
awsSecretAccessKey
stringThe AWS Secret Access Key.
region
RegionEndpointThe region to configure the transfer utility for.
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(string, string, RegionEndpoint, TransferUtilityConfig)
Constructs a new instance of the TransferUtility class.
public TransferUtility(string awsAccessKeyId, string awsSecretAccessKey, RegionEndpoint region, TransferUtilityConfig config)
Parameters
awsAccessKeyId
stringThe AWS Access Key ID.
awsSecretAccessKey
stringThe AWS Secret Access Key.
region
RegionEndpointThe region to configure the transfer utility for.
config
TransferUtilityConfigSpecifies advanced settings.
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
TransferUtility(string, string, TransferUtilityConfig)
Constructs a new instance of the TransferUtility class.
public TransferUtility(string awsAccessKeyId, string awsSecretAccessKey, TransferUtilityConfig config)
Parameters
awsAccessKeyId
stringThe AWS Access Key ID.
awsSecretAccessKey
stringThe AWS Secret Access Key.
config
TransferUtilityConfigSpecifies advanced settings.
Remarks
If a Timeout needs to be specified, use the constructor which takes an AmazonS3Client as a paramater. Use an instance of AmazonS3Client constructed with an AmazonS3Config object with the Timeout specified.
Properties
S3Client
Gets the Amazon S3 client used for making calls into Amazon S3.
public 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.
public void AbortMultipartUploads(string bucketName, DateTime initiatedDate)
Parameters
bucketName
stringThe name of the bucket containing multipart uploads.
initiatedDate
DateTimeThe date before which the multipart uploads were initiated.
AbortMultipartUploadsAsync(string, DateTime, CancellationToken)
Aborts the multipart uploads that were initiated before the specified date.
public Task AbortMultipartUploadsAsync(string bucketName, DateTime initiatedDate, CancellationToken cancellationToken = default)
Parameters
bucketName
stringThe name of the bucket containing multipart uploads.
initiatedDate
DateTimeThe date before which the multipart uploads were initiated.
cancellationToken
CancellationTokenA 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.
Dispose()
Disposes of all managed and unmanaged resources.
public void Dispose()
Dispose(bool)
Implements the Dispose pattern
protected virtual void Dispose(bool disposing)
Parameters
disposing
boolWhether this object is being disposed via a call to Dispose or garbage collected.
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.
public void Download(TransferUtilityDownloadRequest request)
Parameters
request
TransferUtilityDownloadRequestContains 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.
public void Download(string filePath, string bucketName, string key)
Parameters
filePath
stringThe file path where the content from Amazon S3 will be written to.
bucketName
stringThe name of the bucket containing the Amazon S3 object to download.
key
stringThe 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.
public Task DownloadAsync(TransferUtilityDownloadRequest request, CancellationToken cancellationToken = default)
Parameters
request
TransferUtilityDownloadRequestContains all the parameters required to download an Amazon S3 object.
cancellationToken
CancellationTokenA 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.
public Task DownloadAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
filePath
stringThe file path where the content from Amazon S3 will be written to.
bucketName
stringThe name of the bucket containing the Amazon S3 object to download.
key
stringThe key under which the Amazon S3 object is stored.
cancellationToken
CancellationTokenA 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.
public void DownloadDirectory(TransferUtilityDownloadDirectoryRequest request)
Parameters
request
TransferUtilityDownloadDirectoryRequestContains 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
.
public void DownloadDirectory(string bucketName, string s3Directory, string localDirectory)
Parameters
bucketName
stringThe name of the bucket containing the Amazon S3 objects to download.
s3Directory
stringThe directory in Amazon S3 to download.
localDirectory
stringThe 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.
public Task DownloadDirectoryAsync(TransferUtilityDownloadDirectoryRequest request, CancellationToken cancellationToken = default)
Parameters
request
TransferUtilityDownloadDirectoryRequestContains all the parameters required to download objects from Amazon S3 into a local directory.
cancellationToken
CancellationTokenA 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
.
public Task DownloadDirectoryAsync(string bucketName, string s3Directory, string localDirectory, CancellationToken cancellationToken = default)
Parameters
bucketName
stringThe name of the bucket containing the Amazon S3 objects to download.
s3Directory
stringThe directory in Amazon S3 to download.
localDirectory
stringThe local directory to download the objects to.
cancellationToken
CancellationTokenA 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.
public Stream OpenStream(TransferUtilityOpenStreamRequest request)
Parameters
request
TransferUtilityOpenStreamRequestContains 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.
public Stream OpenStream(string bucketName, string key)
Parameters
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.
public Task<Stream> OpenStreamAsync(TransferUtilityOpenStreamRequest request, CancellationToken cancellationToken = default)
Parameters
request
TransferUtilityOpenStreamRequestContains all the parameters required for the OpenStream operation.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
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.
public Task<Stream> OpenStreamAsync(string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
bucketName
stringThe name of the bucket.
key
stringThe object key.
cancellationToken
CancellationTokenA cancellation token that can be used by other objects or threads to receive notice of cancellation.
Returns
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.
public void Upload(TransferUtilityUploadRequest request)
Parameters
request
TransferUtilityUploadRequestContains 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.
public void Upload(Stream stream, string bucketName, string key)
Parameters
stream
StreamThe stream to read to obtain the content to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.
key
stringThe 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.
public void Upload(string filePath, string bucketName)
Parameters
filePath
stringThe file path of the file to upload.
bucketName
stringThe 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.
public void Upload(string filePath, string bucketName, string key)
Parameters
filePath
stringThe file path of the file to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
key
stringThe 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.
public Task UploadAsync(TransferUtilityUploadRequest request, CancellationToken cancellationToken = default)
Parameters
request
TransferUtilityUploadRequestContains all the parameters required to upload to Amazon S3.
cancellationToken
CancellationTokenA 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.
public Task UploadAsync(Stream stream, string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
stream
StreamThe stream to read to obtain the content to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the stream to.
key
stringThe key under which the Amazon S3 object is stored.
cancellationToken
CancellationTokenA 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.
public Task UploadAsync(string filePath, string bucketName, string key, CancellationToken cancellationToken = default)
Parameters
filePath
stringThe file path of the file to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
key
stringThe key under which the Amazon S3 object is stored.
cancellationToken
CancellationTokenA 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.
public Task UploadAsync(string filePath, string bucketName, CancellationToken cancellationToken = default)
Parameters
filePath
stringThe file path of the file to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the file to.
cancellationToken
CancellationTokenA 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.
public void UploadDirectory(TransferUtilityUploadDirectoryRequest request)
Parameters
request
TransferUtilityUploadDirectoryRequestThe 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.
public void UploadDirectory(string directory, string bucketName)
Parameters
directory
stringThe source directory, that is, the directory containing the files to upload.
bucketName
stringThe 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.
public void UploadDirectory(string directory, string bucketName, string searchPattern, SearchOption searchOption)
Parameters
directory
stringThe source directory, that is, the directory containing the files to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
searchPattern
stringA pattern used to identify the files from the source directory to upload.
searchOption
SearchOptionA 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.
public Task UploadDirectoryAsync(TransferUtilityUploadDirectoryRequest request, CancellationToken cancellationToken = default)
Parameters
request
TransferUtilityUploadDirectoryRequestThe request that contains all the parameters required to upload a directory.
cancellationToken
CancellationTokenA 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.
public Task UploadDirectoryAsync(string directory, string bucketName, string searchPattern, SearchOption searchOption, CancellationToken cancellationToken = default)
Parameters
directory
stringThe source directory, that is, the directory containing the files to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
searchPattern
stringA pattern used to identify the files from the source directory to upload.
searchOption
SearchOptionA search option that specifies whether to recursively search for files to upload in subdirectories.
cancellationToken
CancellationTokenA 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.
public Task UploadDirectoryAsync(string directory, string bucketName, CancellationToken cancellationToken = default)
Parameters
directory
stringThe source directory, that is, the directory containing the files to upload.
bucketName
stringThe target Amazon S3 bucket, that is, the name of the bucket to upload the files to.
cancellationToken
CancellationTokenA 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.