Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 列出具有特定存储类的S3 bucket对象_Amazon Web Services_Amazon S3_Aws Cli_Amazon Glacier - Fatal编程技术网

Amazon web services 列出具有特定存储类的S3 bucket对象

Amazon web services 列出具有特定存储类的S3 bucket对象,amazon-web-services,amazon-s3,aws-cli,amazon-glacier,Amazon Web Services,Amazon S3,Aws Cli,Amazon Glacier,从冰川获取对象非常耗时,所以我决定改用S3IA存储类。 我需要列出我的bucket中具有Glacier storage类的所有对象(我通过LifeCycle策略配置了它),并将其更改为S3 IA 有什么脚本或工具吗?您可以使用 列出对象将返回存储类,如果您想在冰川 aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`]' 然后,您只需要获取匹配的密钥列表 aws s3ap

从冰川获取对象非常耗时,所以我决定改用S3IA存储类。 我需要列出我的bucket中具有Glacier storage类的所有对象(我通过LifeCycle策略配置了它),并将其更改为S3 IA

有什么脚本或工具吗?

您可以使用

列出对象
将返回
存储类
,如果您想在
冰川

aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`]'
然后,您只需要获取匹配的密钥列表

aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`][Key]' --output text
然后需要通过更改密钥的存储类来复制对象

aws s3api list-objects --bucket %bucket_name% --query 'Contents[?StorageClass==`GLACIER`][Key]' --output text
| xargs -I {} aws s3 cp s3://bucket_name/{} s3://bucket_name/{} --storage-class STANDARD_IA

而且。。。如果需要在windows中从Powershell运行此操作,我必须执行以下操作:

aws s3api list-objects --bucket Your_Bucket --query 'Contents[?StorageClass==`STANDARD`][Key]' --output text | foreach { aws s3 cp s3://Your_Bucket/$_ s3://Your_Bucket/$_ --storage-class REDUCED_REDUNDANCY }

你知道如何使用aws sdk通过javascript实现吗