Amazon.S3.Transfer.TransferUtility.DownloadAsync C# (CSharp) Method

DownloadAsync() public method

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 DownloadAsync ( TransferUtilityDownloadRequest request, CancellationToken cancellationToken = default(CancellationToken) ) : Task
request TransferUtilityDownloadRequest /// Contains all the parameters required to download an Amazon S3 object. ///
cancellationToken System.Threading.CancellationToken /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        public Task DownloadAsync(TransferUtilityDownloadRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var command = new DownloadCommand(this._s3Client, request);
            return command.ExecuteAsync(cancellationToken);
        }

Usage Example

 public async Task DownloadFile(IStorageFile storageFile, string bucket, string key, AWSCredentials credentials, CancellationToken cancellationToken)
 {
     var s3Client = new AmazonS3Client(credentials, RegionEndpoint.USEast1);
     using (var transferUtility = new TransferUtility(s3Client))
     {
         var downloadRequest = new TransferUtilityDownloadRequest
         {
             BucketName = bucket,
             Key = key,
             StorageFile = storageFile
         };
         downloadRequest.WriteObjectProgressEvent += OnWriteObjectProgressEvent;
         await transferUtility.DownloadAsync(downloadRequest, cancellationToken);
     }
 }
All Usage Examples Of Amazon.S3.Transfer.TransferUtility::DownloadAsync