I'm using S3 to host a static website for a portfolio. For each webpage the .htmlextension is removed. The problem with this is that AWS automatically categorizes the file as binary/octet-stream. The problem here is that when you access the extension such as myportfolio.com/contact instead of rendering the page, the file just downloads into the downloads folder.
By going to
[Object] → properties → metadata → content-type
I am able to change the type to text/html which causes the file to render instead of downloading.
Now after having made a change to all the files and re-uploading them using AWS Cli:
AWS s3 sync . s3://[bucketname]
the files went back to the old content-type. How do I permanently set the content type on these files?
Have you tried setting the --content-type flag? For example,
AWS s3 sync . s3://[bucketname] --content-type "text/html"
More info on this can be found here in the sync documentation
UPDATE: try this command for deployment,
aws s3 sync --acl public-read --sse --delete . s3://[bucketname]
--acl sets the files to be public read, --sse stores files encrypted, --delete removes files that are not in your local file.