小编Ale*_*don的帖子

将 GLACIER 对象恢复到 S3 标准层

我正在编写一个可以从 Glacier 恢复对象的代码。我们将使用的层是标准层。我正在关注这个文档:

client.restor_object 上的 Bot3 文档

另请参阅 github 帐户中的示例:https ://github.com/boto/boto3/issues/380

此代码无需 RestoreRequest 中的 Tier 选项即可工作。

 import boto3

s3 = boto3.resource('s3')
bucket = s3.Bucket('datasets-imported-imdb')
for obj_sum in bucket.objects.all():
    if obj_sum.key == 'testfile.mov':
        print(f'file being restored {obj_sum.key}')
        resp = bucket.meta.client.restore_object(
            Bucket=obj_sum.bucket_name,
            Key=obj_sum.key,
            RestoreRequest={'Days': 1,'Tier': 'Standard'}    
        )
    else:
        print(f'file not being restored {obj_sum.key}')
Run Code Online (Sandbox Code Playgroud)

这是回溯:

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    resp = bucket.meta.client.restore_object(
  File "/home/alex_anadon/.local/lib/python3.8/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/alex_anadon/.local/lib/python3.8/site-packages/botocore/client.py", line 676, …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 amazon-web-services python-3.x boto3

4
推荐指数
1
解决办法
4781
查看次数