如何在对象存储中设置文件的生存时间?你知道吗
查看https://github.com/softlayer/softlayer-object-storage-python/blob/master/object_storage/storage_object.py中的代码,它接受(self、data、check\md5)而没有TTL选项。你知道吗
sl_storage = object_storage.get_client(
username = environment['slos_username'],
password = environment['api_key'],
auth_url = environment['auth_url']
)
# get container
sl_container = sl_storage.get_container(environment['object_container'])
# create "pointer" to cointainer file fabfile.zip
sl_file = sl_container[filename]
myzip = open(foldername + filename, 'rb')
sl_file.create()
sl_file.send(myzip, TIME_TO_LIVE_PARAM=100)
我也试过根据https://github.com/softlayer/softlayer-object-storage-python/blob/master/object_storage/container.py
sl_file['ttl'] = timetolive
但它不起作用。你知道吗
谢谢!你知道吗
您需要确保“ttl”在头文件中可用,“ttl”头文件在您的容器启用CDN时可用。你知道吗
因此,要验证ttl标头是否存在,可以使用以下代码行:
然后可以使用以下行代码更新tll:
如果ttl值不存在并且您启用了cdn,请尝试使用以下行代码创建标头:
敬礼
您需要设置标题“X-Delete-At:1417341600”,其中1417341600是Unix时间戳参见此处的更多信息http://docs.openstack.org/developer/swift/overview_expiring_objects.html
使用Python客户端,可以使用update方法: https://github.com/softlayer/softlayer-object-storage-python/blob/master/object_storage/storage_object.py#L210-L216
敬礼
相关问题 更多 >
编程相关推荐