public void WriteResponseStreamToFile(string filePath, bool append)
{
CreateDirectory(filePath);
Stream downloadStream = CreateDownloadStream(filePath, append);
using (downloadStream)
{
long current = 0;
byte[] buffer = new byte[S3Constants.DefaultBufferSize];
int bytesRead = 0;
long totalIncrementTransferred = 0;
while ((bytesRead = this.ResponseStream.Read(buffer, 0, buffer.Length)) > 0)
{
downloadStream.Write(buffer, 0, bytesRead);
current += bytesRead;
totalIncrementTransferred += bytesRead;
if (totalIncrementTransferred >= AWSSDKUtils.DefaultProgressUpdateInterval ||
current == this.ContentLength)
{
this.OnRaiseProgressEvent(filePath, totalIncrementTransferred, current, this.ContentLength);
totalIncrementTransferred = 0;
}
}
ValidateWrittenStreamSize(current);
}
}