AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Downloads the content from Amazon S3 based on the request and returns response metadata.
To track the progress of the download, add an event listener to the request's WriteObjectProgressEvent.
For .NET Core this operation is only available in asynchronous form. Please refer to DownloadWithResponseAsync.
Namespace: Amazon.S3.Transfer
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z
public virtual TransferUtilityDownloadResponse DownloadWithResponse( TransferUtilityDownloadRequest request )
Contains all the parameters required to download an Amazon S3 object.
This method uses parallel downloads to significantly improve throughput compared to the standard Amazon.S3.Transfer.ITransferUtility.Download(Amazon.S3.Transfer.TransferUtilityDownloadRequest) method.
How it works:
Multipart Download Strategy:
The Amazon.S3.Transfer.BaseDownloadRequest.MultipartDownloadType property controls how parts are downloaded (default: MultipartDownloadType.PART):
When to use PART vs RANGE:
Configuration Options:
You can customize the download behavior using Amazon.S3.Transfer.TransferUtilityConfig:
var config = new TransferUtilityConfig
{
// Control how many parts download in parallel (default: 10)
ConcurrentServiceRequests = 20
};
var transferUtility = new TransferUtility(s3Client, config);
Use Amazon.S3.Transfer.TransferUtilityConfig.ConcurrentServiceRequests to control parallel download threads.
You can also customize the part size per request using Amazon.S3.Transfer.BaseDownloadRequest.PartSize:
var request = new TransferUtilityDownloadRequest
{
BucketName = "my-bucket",
Key = "my-key",
FilePath = "local-file.txt",
PartSize = 16 * 1024 * 1024, // Use 16MB parts instead of default 8MB
MultipartDownloadType = MultipartDownloadType.RANGE // Enable RANGE mode to use custom PartSize
};
var response = transferUtility.DownloadWithResponse(request);
Additional Performance Settings:
You can also tune the S3 client's Amazon.Runtime.ClientConfig.BufferSize property to control the buffer size used when reading from S3 response streams and writing to the local file. The default buffer size is 8KB. Increasing this value may improve throughput for large downloads at the cost of increased memory usage.
var s3Config = new AmazonS3Config
{
BufferSize = 64 * 1024 // Use 64KB buffer instead of default 8KB
};
var s3Client = new AmazonS3Client(s3Config);
var transferUtility = new TransferUtility(s3Client);
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.7.2 and newer