/// <summary>
/// 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 be assumed.
/// </summary>
/// <param name="request">
/// Contains all the parameters used to download an Amazon S3 object.
/// </param>
public void Download(TransferUtilityDownloadRequest request)
{
if (!request.IsSetBucketName())
{
throw new ArgumentNullException("bucketName", "The bucketName Specified is null or empty!");
}
if (!request.IsSetFilePath())
{
throw new ArgumentNullException("filePath", "The filepath Specified is null or empty!");
}
if (!request.IsSetKey())
{
throw new ArgumentNullException("key", "The Key Specified is null or empty!");
}
GetObjectRequest getRequest = convertToGetObjectRequest(request);
GetObjectResponse response = this._s3Client.GetObject(getRequest);
response.WriteObjectProgressEvent += request.EventHandler;
response.WriteResponseStreamToFile(request.FilePath);
}