title: Amazon S3 MultiPartUpload C# not working
body: <p>I've been struggling for hours with this problem, I hope you can help me.  Somehow my compiler will only accept InitiateMultipartUploadAsync and not the regular InitiateMultipartUpload and absolutely requires the callback as parameters to compile, but I can figure out what callback function to give him.</p>
  
  <pre><code>private static async Task UploadObjectAsync()
  {
      // Create list to store upload part responses.
      List&lt;UploadPartResponse&gt; uploadResponses = new List&lt;UploadPartResponse&gt;();
      // Setup information required to initiate the multipart upload.
      InitiateMultipartUploadRequest initiateRequest = new InitiateMultipartUploadRequest
      {
          BucketName = "XXXXXXXXX",
          Key = "videos/multipart"
      };
  
      // Initiate the upload.
  
      InitiateMultipartUploadResponse initResponse =
          await S3Client.InitiateMultipartUploadAsync(initiateRequest);
  
      // Upload parts.
      long contentLength = new FileInfo("videotest").Length;
      long partSize = 5 * (long)Math.Pow(2, 20); // 5 MB
  
      try
      {
          Console.WriteLine("Uploading parts");
  
          long filePosition = 0;
          for (int i = 1; filePosition &lt; contentLength; i++)
          {
              UploadPartRequest uploadRequest = new UploadPartRequest
              {
                  BucketName = "XXXXXXXX",
                  Key = "videos/multipart",
                  UploadId = initResponse.UploadId,
                  PartNumber = i,
                  PartSize = partSize,
                  FilePosition = filePosition,
                  FilePath = "videotest"
              };
  
              // Track upload progress.
              uploadRequest.StreamTransferProgress +=
                  new EventHandler&lt;StreamTransferProgressArgs&gt;(UploadPartProgressEventCallback);
  
              // Upload a part and add the response to our list.
              uploadResponses.Add(await S3Client.UploadPartAsync(uploadRequest));
  
              filePosition += partSize;
          }
  
          // Setup to complete the upload.
          CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest
          {
              BucketName = "XXXXXXXXXXX",
              Key = "videos/multipart",
              UploadId = initResponse.UploadId
          };
          completeRequest.AddPartETags(uploadResponses);
  
          // Complete the upload.
  
          CompleteMultipartUploadResponse completeUploadResponse =
              await S3Client.CompleteMultipartUploadAsync(completeRequest);
      }
      catch (Exception exception)
      {
          Console.WriteLine("An AmazonS3Exception was thrown: {0}", exception.Message);
  
          // Abort the upload.
          AbortMultipartUploadRequest abortMPURequest = new AbortMultipartUploadRequest
          {
              BucketName = "XXXXXXXXX",
              Key = "videos/multipart",
              UploadId = initResponse.UploadId
          };
          await S3Client.AbortMultipartUploadAsync(abortMPURequest);
      }
  }
  public static void UploadPartProgressEventCallback(object sender, StreamTransferProgressArgs e)
  {
      // Process event. 
      Console.WriteLine("{0}/{1}", e.TransferredBytes, e.TotalBytes);
  }
  </code></pre>
  
  <p>This code was inspired from the offical aws example : <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/LLuploadFileDotNet.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/AmazonS3/latest/dev/LLuploadFileDotNet.html</a>  So I really don't understand why this doesn't work !  Currently with above code, Visual Studio is telling me that InitiateMultipartUploadAsync, UploadPartAsync, CompleteMultipartUploadAsync and AbortMultipartUploadAsync all require a callback function, but 1) examples says callback is optional 2) every callback I tried doesn't work.  Thanks in advance</p>