Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

1 Answers

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

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!