本文介绍了如何读取S3存储桶中每个项目的元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用以下命令在S3存储桶中的每个项目上设置Cache-Control
元数据(来自此答案) :
I can set Cache-Control
metadata on every item in an S3 bucket using the following command (from this answer):
aws s3 cp s3://mybucket s3://mybucket --recursive --metadata-directive REPLACE \
--cache-control max-age=86400
是否有一种方法可以读取存储桶中每个项目的Cache-Control
元数据?
Is there a way to read the Cache-Control
metadata for every item in a bucket?
推荐答案
此bash单行代码应该可以工作(但是它很慢,因为它为每个对象发送单独的请求):
This bash one-liner should work (but it is very slow since it sends separate request for each object):
IFS=$'\n'; for object in `aws s3 ls s3://my-bucket-name --recursive | tr -s ' ' | cut -d' ' -f4-`; do echo $object `aws s3api head-object --bucket my-bucket-name --key $object --query CacheControl` ; done
这篇关于如何读取S3存储桶中每个项目的元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!