如何为Amazon S3中存储桶中的所有图像设置过期标头 [英] How to set expires headers to all images in a bucket in Amazon S3
本文介绍了如何为Amazon S3中存储桶中的所有图像设置过期标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们在Amazon S3的存储桶中有大约10,000多张图像,如何一次性设置所有图像上的expires标头?
We have around 10,000+ images in a bucket in Amazon S3, how can I set the expires header on all of the images in one go?
推荐答案
请注意,我使用AWS CLI找到了很好的解决方案:
Just a heads up that I found a great solution using the AWS CLI:
aws s3 cp s3://bucketname/optional_path s3://bucketname/optional_path --recursive --acl public-read --metadata-directive REPLACE --cache-control max-age=2592000
这会将Cache-Control设置为30天.请注意,您可以选择复制或替换以前的标头数据.由于AWS会自动为每种媒体类型包括正确的meta内容类型数据,而且我的标头不好,因此我选择覆盖所有内容.
This will set the Cache-Control for 30 days. Note that you have the option to copy or replace the previous header data. Since AWS will automatically include the right meta content-type data for each media type and I had some bad headers I just chose to overwrite everything.
这篇关于如何为Amazon S3中存储桶中的所有图像设置过期标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文