duncanlock.net

Fixing content types in s3 using the AWS CLI

I had an issue where the AWS CLI wasn’t guessing the content-type of SVG files correctly on sync and was setting them to application/octet-stream - the default “I don’t know” mimetype. There’s a proper fix to make the mimetype guessing work here. This is a quick fix for stuff that’s already been uploaded to s3:

$ aws s3 cp --exclude "*" --include "*.svg" --content-type="image/svg+xml" --metadata-directive="REPLACE" --recursive --acl public-read ./output/ s3://<bucketname>

This probably wipes out some of the other metadata on the files, but sets content-type & acl correctly for uploading SVG files to a website hosted on s3.

References


Related Posts


Comments