2017-07-14 7 views
0

私のオブジェクトには、このオブジェクトがいつ削除されるかを定義する属性'Expiration': 'expiry-date="Sun, 16 Jul 2017 00:00:00 GMT"'があります。この日付はライフサイクルルールからS3で設定されます。この日付をboto3からこのオブジェクトを後で自動更新する方法はありますか?ところで、私は属性x-amz-expirationに同じ日時を見つけました。あなたのオブジェクトは、おそらくすでになくなっていますがboto3 S3:オブジェクトの `expiry-date`を更新します

答えて

0

は、すでにその特定のトピックのための答え質問があります:s3 per object expiry

TL; DR:有効期限は、S3バケットごとですが、touchをエミュレートすることにより、あなたは、個々の有効期限を延長することができますオブジェクト。

#!/usr/bin/env python3 

import boto3 

client = boto3.client('s3') 

# Upload the object initially. 
client.put_object(Body='file content', 
        Bucket='your-bucket', 
        Key='testfile') 

# Replace the object with itself. That will "reset" the expiry timer. 
# As S3 only allows that in combination of changing metadata, storage 
# class, website redirect location or encryption attributes, simply 
# add some metadata. 
client.copy_object(CopySource='your-bucket/testfile', 
        Bucket='your-bucket', 
        Key='testfile', 
        Metadata={'foo': 'bar'}, 
        MetadataDirective='REPLACE') 
:あなたはそのための boto3 - 溶液とリンクし、質問に記載されていないような解決策を求めたよう

、ここboto3を有するものです

関連する問題