站点图标 星露谷值班站长

Python 阿里云OSS上传图片指定Cache-Control

python 代码示例如下

import oss2
................. 省略代码            

for param in (access_key_id, access_key_secret, bucket_name, endpoint):
                assert '<' not in param, '请设置参数:' + param
            bucket = oss2.Bucket(oss2.Auth(access_key_id, access_key_secret), endpoint, bucket_name)
            with open(oss2.to_unicode(src_name), 'rb') as f:
                bucket.put_object(det_name, f,headers={"Cache-Control":"max-age=2592000"})

bucket.put_object(det_name, f,headers={“Cache-Control”:”max-age=2592000″})

退出移动版