Amazon.S3.Util.AmazonS3Util.MakeStreamSeekable C# (CSharp) Method

MakeStreamSeekable() public static method

Converts a non-seekable stream into a System.IO.MemoryStream. A MemoryStream's position can be moved arbitrarily
MemoryStreams use byte arrays as their backing store. Please use this judicially as it is likely that a very large stream will cause system resources to be used up.
public static MakeStreamSeekable ( System input ) : Stream
input System The stream to be converted
return System.IO.Stream
        public static System.IO.Stream MakeStreamSeekable(System.IO.Stream input)
        {
            System.IO.MemoryStream output = new System.IO.MemoryStream();
            const int readSize = 32 * 1024;
            byte[] buffer = new byte[readSize];

            int count = 0;
            using (input)
            {
                while ((count = input.Read(buffer, 0, readSize)) > 0)
                {
                    output.Write(buffer, 0, count);
                }
            }

            output.Position = 0;
            return output;
        }