s3.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:sqlalchemy-media 作者: pylover 项目源码 文件源码
def _upload_file(self, url: str, data: str, content_type: str,
                     rrs: bool = False):
        ensure_aws4auth()

        auth = AWS4Auth(self.access_key, self.secret_key, self.region, 's3')
        if rrs:
            storage_class = 'REDUCED_REDUNDANCY'
        else:
            storage_class = 'STANDARD'
        headers = {
            'Cache-Control': 'max-age=' + str(self.max_age),
            'x-amz-acl': self.acl,
            'x-amz-storage-class': storage_class
        }
        if content_type:
            headers['Content-Type'] = content_type
        res = requests.put(url, auth=auth, data=data, headers=headers)
        if not 200 <= res.status_code < 300:
            raise S3Error(res.text)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号