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 and writes it to the specified file, returning response metadata.
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( String filePath, String bucketName, String key )
The file path where the downloaded content will be written.
The name of the bucket containing the Amazon S3 object to download.
The key under which the Amazon S3 object is stored.
This method uses parallel downloads to significantly improve throughput compared to the standard Amazon.S3.Transfer.ITransferUtility.Download(System.String,System.String,System.String) 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.
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