2017-07-14 80 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;博士:有效期爲每S3鬥,而是通過模擬touch可以延長的個別到期日對象。

當你問一個boto3 - 溶液爲和這樣的解決方案中的鏈接問題沒有注意,這裏是一個與boto3:

#!/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')