title: Put object to Amazon S3 using .net async
body: <p>I want to convert the AWS S3 async methods into a Task using something like this:</p>
  
  <pre><code>using (var client = AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey))
  {
      var request = new PutObjectRequest();
      // ... set request properties ...
  
      await Task.Factory.FromAsync&lt;PutObjectRequest, PutObjectResponse&gt;(
          client.BeginPutObject,
          client.EndPutObject,
          request,
          null
      );
  }
  </code></pre>
  
  <p>However, I get the following exception:</p>
  
  <pre><code>System.ArgumentException: The IAsyncResult object was not returned from the corresponding asynchronous method on this class.
  Parameter name: asyncResult
     at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
     at Amazon.S3.AmazonS3Client.getResponseCallback[T](IAsyncResult result)
     at Amazon.S3.AmazonS3Client.endOperation[T](IAsyncResult result)
     at Amazon.S3.AmazonS3Client.EndPutObject(IAsyncResult asyncResult)
     at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
  </code></pre>
  
  <p>Is my call to <code>FromAsync</code> incorrect or is something else going wrong here?</p>
  
  <p>P.S.</p>
  
  <ul>
  <li>.NET Framework 4.5</li>
  <li>AWSSDK version 1.5.17.0</li>
  </ul>