Amazon.S3.Model.GetObjectResponse.WriteResponseStreamToFile C# (CSharp) Метод

WriteResponseStreamToFile() публичный Метод

Writes the content of the ResponseStream a file indicated by the filePath argument.
public WriteResponseStreamToFile ( string filePath, bool append ) : void
filePath string The location where to write the ResponseStream
append bool Whether or not to append to the file if it exists
Результат void
        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);
            }
        }

Same methods

GetObjectResponse::WriteResponseStreamToFile ( string filePath ) : void