title: Specify Content-Type in AWS PHP's upload function
body: <p>I am migrating my code from AWS PHP SDK1 to SDK2 (<a href="https://github.com/aws/aws-sdk-php" rel="noreferrer">https://github.com/aws/aws-sdk-php</a>).</p>
  
  <p>I have an image uploader.
  In my previous version, I would specify the Content-Type of my image like so:</p>
  
  <pre><code>$response = $this-&gt;s3-&gt;create_object(
                  $bucket,
                  $key,
                  array(
                      'fileUpload'=&gt;$file_resource,
                      'contentType'=&gt;$mime, 
                      'acl' =&gt; AmazonS3::ACL_PUBLIC,
                      )
                  );
  </code></pre>
  
  <p>This is my new version:</p>
  
  <pre><code>$response = $this-&gt;s3-&gt;upload(
                      $bucket, 
                      $key, 
                      $file_resource, 
                      'public-read',
                      array('params' =&gt; array('Metadata' =&gt; array('ContentType'=&gt;$mime)))
                      );
  </code></pre>
  
  <p>I've tried different spellings of ContentType, in the S3 site it modifies the name to look like 'x-amz-meta-contenttype', while the value of 'Content-Type' is the default 'binary/octet-stream'.</p>
  
  <p>I've also tried using the EntityBody feature, but same results:</p>
  
  <pre><code>$response = $this-&gt;s3-&gt;upload(
                      $this-&gt;bucket, 
                      $to, 
                      EntityBody::factory($file_resource), 
                      'public-read',
                      array('params' =&gt; array('Metadata' =&gt; array('ContentType'=&gt;$mime)))
                      );
  </code></pre>
  
  <p>How do I set the content-type in this new API?</p>
  
  <p>EDIT: I see somewhere in the documentation:</p>
  
  <blockquote>
    <p>The AWS SDK for PHP will attempt to automatically determine the most
    appropriate Content-Type header used to store the object. If you are
    using a less common file extension and your Content-Type header is not
    added automatically, you can add a Content-Type header by passing a
    ContentType option to the operation.</p>
  </blockquote>
  
  <p>First off, I am uploading simple images, yet according to my S3 dashboard, they are uploaded as 'binary/octet-stream'. About their second point, I've tried many combinations of arrays with 'ContentType' I'm not sure why it's not working...</p>