How to update content-type of files on aws s3 in batch

Please install and config aws CLI first. The tutorial is at https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

Assume that the files you want to update are at s3://foo/bar/txt/ and your target conent-type is text/plain, run the following command:

aws s3 cp \
s3://foo/bar/txt/ \
s3://foo/bar/txt/ \
--no-guess-mime-type \
--content-type="text/plain" \
--metadata-directive="REPLACE" \
--recursive
Posted on 2022-03-25