如何通过 boto3 更改现有密钥的存储 class
How to change storage class of existing key via boto3
使用 AWS S3 服务时,我需要将现有密钥的存储 class 从标准更改为 STANDARD_IA。
change_storage_class
来自 boto 的内容在 boto3 中不存在。
Boto3 中的等价物是什么?
来自 amazon doc
You can also change the storage class of an object that is already stored in Amazon S3 by copying it to the same key name in the same bucket. To do that, you use the following request headers in a PUT Object copy request:
x-amz-metadata-directive
set to COPY
x-amz-storage-class
set to STANDARD
, STANDARD_IA
, or REDUCED_REDUNDANCY
就 boto3 copy code 而言,这看起来像
import boto3
s3 = boto3.client('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
s3.copy(
copy_source, 'mybucket', 'mykey',
ExtraArgs = {
'StorageClass': 'STANDARD_IA',
'MetadataDirective': 'COPY'
}
)
使用 AWS S3 服务时,我需要将现有密钥的存储 class 从标准更改为 STANDARD_IA。
change_storage_class
来自 boto 的内容在 boto3 中不存在。
Boto3 中的等价物是什么?
来自 amazon doc
You can also change the storage class of an object that is already stored in Amazon S3 by copying it to the same key name in the same bucket. To do that, you use the following request headers in a PUT Object copy request:
x-amz-metadata-directive
set toCOPY
x-amz-storage-class
set toSTANDARD
,STANDARD_IA
, orREDUCED_REDUNDANCY
就 boto3 copy code 而言,这看起来像
import boto3
s3 = boto3.client('s3')
copy_source = {
'Bucket': 'mybucket',
'Key': 'mykey'
}
s3.copy(
copy_source, 'mybucket', 'mykey',
ExtraArgs = {
'StorageClass': 'STANDARD_IA',
'MetadataDirective': 'COPY'
}
)