Bug - Extension/file-type issue when uploading S3 assets
Jul 13, 2020
š¤ Problem
Files uploaded to S3 have content type application/octet-stream
unless files explicitly have a .html extension.
This is super annoying if you are are working with a statically served site and want your files to get linked without that .html
extension.
ā Solution
The first thing you can do is go into S3 directly and change the meta tags on the object that you want.
If you find your object in the console, click on properties, then click on metadata
, you'll can edit the type to Content-Type: text/html
.
If you are uploading objects from a script I've also found this to work:
aws s3 sync ./MY_FILE s3://[BUCKET_NAME] --acl public-read --no-guess-mime-type --content-type=text/html
Modify that line to meet your needs.
Why this happened?
This site is served through Cloudfront and an S3 bucket. Because of this, it doesn't hit a server I control, it only serves assets that are requested.
This is great but it leads to this error because I don't want my site to link to ugly .html
urls. This is a pretty silly thing to worry about. No one really pays attention to links, but I had to figure this out once I started.

I'm Wes. I live in Boston and work on Wonderment.