我已经使用boto将几个文件上传到 Amazon S3 。但是,我未能设置生命周期 using 语句(我知道这可以使用AWS 管理控制台来完成,但我需要让每个用户决定要保留文件多长时间)。
S3的boto API 参考正确记录了configure_lifecycle(lifecycle_config, headers=None)作为解决方案,但我无法配置它。任何人都可以更正我的代码吗?
谢谢!
key='key'
secretkey='secretkey'
#build the connection
conn = S3Connection(key, secretkey)
bucket = conn.create_bucket('przm')
k=Key(bucket)
#select and upload the file
name1='run1'
k.key=name1
k.set_contents_from_filename('RUN')
link1='https://s3.amazonaws.com/przm/'+name1
#allow anyone can download this file
k.set_acl('public-read-write')
#delete this file after one day. Can anyone give me some help here?
configure_lifecycle(lifecycle_config, headers=None)