python - Boto3上传ServerSideEncryption

标签 python python-3.x amazon-web-services amazon-s3 boto3

由于 SSE,我收到拒绝访问错误 如何修改我当前的代码以包含 SSE 的形式 ServerSideEncryption='AES256'

 def download(self):
    s3 = boto3.client('s3')
    try:
        with open(self.flow_cells +'.zip', 'wb') as data:
            s3.download_fileobj(self.source_s3_bucket, self.source_key, data)
        return True
    except botocore.exceptions.ClientError as error:
        print(error.response['Error']['Code'])

def upload(self):
    s3 = boto3.client('s3')
    try:
        with open(self.flow_cells +'.zip', 'rb') as data:
            s3.upload_fileobj(data, self.output_s3_bucket, self.flow_cells +'.zip')
        return True
    except botocore.exceptions.ClientError as error:
        print(error.response['Error']['Code'])

最佳答案

future 的修复是

def upload(self):
    s3 = boto3.client('s3')
    try:
        with open(self.flow_cells +'.zip', 'rb') as data:
            s3.upload_fileobj(data, self.output_s3_bucket, self.flow_cells +'.zip',ExtraArgs={'ServerSideEncryption': 'AES256'})
        return True
    except botocore.exceptions.ClientError as error:
        print(error.response['Error']['Code'])

关于python - Boto3上传ServerSideEncryption,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50634193/

相关文章:

python - 按列名称为数据框的每一列创建一个数组

python - 计算轨迹(路径)中的转折点/枢轴点

python - python 中的 __qualname__ 是什么?

javascript - 为 AWS SDK JavaScript V3 重试设置 customBackoff

amazon-web-services - Terraform 变量默认值和嵌套值的描述

python - 在 python 中使用 "*"

python - Pyramid :为由 route_url 构造的每个 URL 扩展查询字符串

python - 在 Python 中形成 Json 模型的问题

Python 骰子脚本失败

Ruby1.9 和 Amazon SQS?