简体   繁体   中英

Boto3 upload ServerSideEncryption

I am getting an accessed denied error due to SSE How do I modify my current code to include SSE in the form of 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'])

fix for future was

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'])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM