I am trying to set up static hosting for S3 websites, but it returns 403 to any of my objects that do not have the Content-Type metadata field set in the AWS console. I cannot figure out how to do this using the AWS CLI tool.
Using the --metadata parameter, a message appears:
$ aws s3api put-object --bucket <bucket> --key foo.html --body foo.html --metadata Content-Type=text/html { "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\"" } $ aws s3api head-object --bucket <bucket> --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" } }
But the Content-Type field of the object does not appear in the "Metadata" section of the AWS console, and I get 403 when I try to access the file in the browser.
Using the --content-type option also does not work:
$ aws s3api put-object --bucket <bucket> --key foo.html --body foo.html --content-type text/html { "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\"" } $ aws s3api head-object --bucket <bucket> --key foo.html { "AcceptRanges": "bytes", "ContentType": "text/html", "LastModified": "Wed, 15 Apr 2015 06:46:49 GMT", "ContentLength": 189, "ETag": "\"fd5ff7743e5ed1e1c304eb1c34e8e39f\"", "Metadata": {} }
While it seems that some special property ContentType , the AWS console still does not have a Content-Type metadata field, nor can I access the file in the browser.
I also tried similar commands ( aws s3 cp , aws s3 sync ), no luck. My bucket policy is set to public.
amazon-s3 amazon-web-services aws-cli
Alek Storm
source share