title: How do I set Content-Type when uploading to S3 with AWS CLI?
body: <p>I'm trying to set up S3 static website hosting, but it appears to return 403 on any of my objects that don't have the <code>Content-Type</code> metadata field set in the AWS console. I cannot figure out how to do this with the AWS CLI tool.</p>
  
  <p>Using the <code>--metadata</code> option appears to work:</p>
  
  <pre><code>$ aws s3api put-object --bucket &lt;bucket&gt; --key foo.html --body foo.html --metadata Content-Type=text/html
  {
      "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\""
  }
  $ aws s3api head-object --bucket &lt;bucket&gt; --key foo.html
  {
      "AcceptRanges": "bytes",
      "ContentType": "binary/octet-stream",
      "LastModified": "Wed, 15 Apr 2015 06:39:48 GMT",
      "ContentLength": 189,
      "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\"",
      "Metadata": {
          "content-type": "text/html"
      }
  }
  </code></pre>
  
  <p>But the <code>Content-Type</code> field on the object isn't visible in the "Metadata" section of the AWS console, and I get a 403 when trying to access the file in a browser.</p>
  
  <p>Using the <code>--content-type</code> option also doesn't work:</p>
  
  <pre><code>$ aws s3api put-object --bucket &lt;bucket&gt; --key foo.html --body foo.html --content-type text/html
  {
      "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\""
  }
  $ aws s3api head-object --bucket &lt;bucket&gt; --key foo.html
  {
      "AcceptRanges": "bytes",
      "ContentType": "text/html",
      "LastModified": "Wed, 15 Apr 2015 06:46:49 GMT",
      "ContentLength": 189,
      "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\"",
      "Metadata": {}
  }
  </code></pre>
  
  <p>While it appears to set some sort of special <code>ContentType</code> property, there still isn't a <code>Content-Type</code> metadata field in the AWS console, nor can I access the file in a browser.</p>
  
  <p>I've also tried similar commands (<code>aws s3 cp</code>, <code>aws s3 sync</code>), with no luck. I have the bucket policy set to publicly-readable.</p>