TypeError:预期的字符串或类似字节的对象-Python(boto3)

时间:2019-07-17 15:21:44

标签: python amazon-web-services amazon-s3 aws-lambda boto3

我正在尝试使用boto3和put_bucket_encryption()函数在S3存储桶上启用加密。但是,我似乎收到以下错误:

[ERROR] TypeError: expected string or bytes-like object

特别是它在抱怨这一行:

'SSEAlgorithm': 'AES256'

下面是我的代码:

s3_client = boto3.client('s3', region_name='us-east-1')
s3_client.put_bucket_encryption(
  Bucket=bucket,
    ServerSideEncryptionConfiguration={
      'Rules':[
        {
           'ApplyServerSideEncryptionByDefault': {
              'SSEAlgorithm': 'AES256'
           }
         }
      ]   
   }
)

我尝试将整个对象转换为字符串以及它抱怨的那一行,但是无济于事。任何帮助表示赞赏。

0 个答案:

没有答案