title: Copy between two AWS buckets - Stream returned from AWS: HashStream does not support seeking
body: <p>I am trying to re-upload a stream that I just retrieved. It shouldn't really matter that I am using AWS I believe... Maybe my understanding of working with streams is just too limited? :-)</p>
  
  <p>I am using the following method straight from the <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileDotNet.html" rel="noreferrer">AWS documentation</a> to download and upload streams:</p>
  
  <p><em>File upload:</em></p>
  
  <pre><code>public bool UploadFile(string keyName, Stream stream)
  {
  using (client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1))
  {
      try
      {
          TransferUtility fileTransferUtility = new TransferUtility(new AmazonS3Client(Amazon.RegionEndpoint.USEast1));
  
          fileTransferUtility.Upload(stream, bucketName, keyName);
  
          return true;
      }
      catch (AmazonS3Exception amazonS3Exception)
      {
          [...]
      }
  }
  }
  </code></pre>
  
  <p><em>Getting the file:</em></p>
  
  <pre><code>public Stream GetFile(string keyName)
  {    
  using (client = new AmazonS3Client(Amazon.RegionEndpoint.USEast2))
  {
      try
      {
          GetObjectRequest request = new GetObjectRequest
          {
              BucketName = bucketName,
              Key = keyName
          };
  
          GetObjectResponse response = client.GetObject(request);
          responseStream = response.ResponseStream;
  
          return responseStream;
      }
      catch (AmazonS3Exception amazonS3Exception)
      {
          [...]
      }
  }
  }
  </code></pre>
  
  <p>Now, I am trying to combine the two methods: I am getting a stream and immediately want to upload it again. However, I am getting the following error message: <code>System.NotSupportedException : HashStream does not support seeking</code></p>
  
  <p>I am guessing it has something to do that I am getting a stream which is somehow now immediately ready to be uploaded again?</p>
  
  <p>This is how I am trying to get the stream of an existing file (.jpg) and immediately try to upload it with a different filename:</p>
  
  <pre><code>newAWS.UploadFile(newFileName, oldAWS.GetFile(oldFile));
  </code></pre>
  
  <p>Where newAWS and oldAWS are instances of the AWS class, and newFileName is a string :-)
  This is the line I am getting the error message pasted above.</p>
  
  <p>Please let me know if I am missing something obvious here why I would not be able to re-upload a fetched stream. Or could it be that it is related to something else I am not aware of and I am on the wrong track trying to troubleshoot the returned stream?</p>
  
  <p>What I am basically trying to do is to copy one file from an AWS bucket to another using streams. But for some reason I get the error message trying to upload the stream that I just downloaded.</p>
  
  <p>Thank you very much for taking your time digging through my code :-)</p>