title: How to upload an object to AWS S3 with "Transfer-Encoding: chunked"
body: <p>I am using the awssdk for c++ to upload data to an S3 bucket. I am using the method <code>PutObject()</code> of the class <code>Aws::S3::S3Client</code> to upload the data.</p>
  
  <p>However, before uploading the data, I need to know the content-length of the data I am uploading. I need to either set the content-length in the request (the request is of type <code>Aws::S3::Model::PutObjectRequest</code>). Or the awssdk library will try to determine the size of the body by itself (the awssdk does that by seeking to the end of payload data to read its size).</p>
  
  <p>Either way, in my case I don't know yet the content-length of the data I am uploading. I am working on a server that compresses data. I have to wait for the compression to end to know the final size of the compressed data. I don't want to wait for that. Instead, I want to start uploading to S3 as the compressed data is being produced. The way that can be done is to use "Transfer-Encoding: chunked" when sending the HTTP post request to the S3 server. </p>
  
  <p><strong>Is there a way to use <code>Aws::S3::S3Client</code> to upload the data with "Transfer-Encoding: chunked" ? *</strong></p>
  
  <p>I've downloaded the source of the awssdk for c++, I've tweaked it a bit to force send "Transfer-Encoding: chunked" in the http request. But the S3 server returned HTTP error code 501 NotImplemented:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Error&gt;
      &lt;Code&gt;NotImplemented&lt;/Code&gt;
      &lt;Message&gt;A header you provided implies functionality that is not implemented&lt;/Message&gt;
      &lt;Header&gt;Transfer-Encoding&lt;/Header&gt;
      &lt;RequestId&gt;8F55B09D484DD66C&lt;/RequestId&gt;
      &lt;HostId&gt;gZk6zaPcObsTfclz0zXvKGtPT5udzDKigIrm7laD3csG30vhx3pa0eFFS8nh6t9k7XkDeJRm9Z4=&lt;/HostId&gt;
  &lt;/Error&gt;
  </code></pre>