LoginSignup
2
1

More than 5 years have passed since last update.

aws cli で s3のContentTypeとACLを変更

Last updated at Posted at 2018-01-25

何も考えずに boto3 で s3 に 大量のpdfファイルを上げたら、全部 Content-Typebinary/octet-stream になってしまったので、まとめて application/pdf に直したかった話。
ついでに public-read で外部から読めるようにしたかったので、

まとめてこう。

BUCKET="your-bucket"
KEY="path/to/your.pdf"

aws s3api copy-object --bucket "$BUCKET" --copy-source "$BUCKET/$KEY" --key "$KEY" --content-type "application/pdf" --metadata-directive REPLACE
aws s3api put-object-acl --acl public-read --bucket "$BUCKET" --key "$KEY"

確認。

aws s3api head-object --bucket "$BUCKET" --key "$KEY"
aws s3api get-object-acl --bucket "$BUCKET" --key "$KEY"
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1