Python 如何使用smart_open将流写入KMS加密的S3存储桶?

Python 如何使用smart_open将流写入KMS加密的S3存储桶?,python,amazon-web-services,amazon-s3,aws-lambda,Python,Amazon Web Services,Amazon S3,Aws Lambda,我正在尝试使用smart_open将流写入KMS加密的S3存储桶,但没有效果。查看smart_open的代码,似乎有一个测试用例,但我无法运行它: @_test_case def test_s3_encrypted_file(benchmark, uri): text = 'с гранатою в кармане, с чекою в руке' s3_upload = {'ServerSideEncryption': 'AES256'} actual = benchm

我正在尝试使用smart_open将流写入KMS加密的S3存储桶,但没有效果。查看smart_open的代码,似乎有一个测试用例,但我无法运行它:

@_test_case
def test_s3_encrypted_file(benchmark, uri):
    text = 'с гранатою в кармане, с чекою в руке'
    s3_upload = {'ServerSideEncryption': 'AES256'}
    actual = benchmark(write_read, uri, text, 'w', 'r', 'utf-8', s3_upload=s3_upload)
    assert actual == text
我认为这是可行的,但它只是说s3_上传不是一个选项:

file = smart_open.open(url, 'w', transport_params={'session': session, s3_upload={'ServerSideEncryption': 'aws:kms', 'SSEKMSKeyId': key}})
file.write(content)
file.close()

知道我做错了什么吗?

看起来这个参数已经被修改过了,所以它不是
s3\u upload
而是
multipart\u upload\u kwargs

根据您的示例,我刚刚实现了这一点:

file = smart_open.open(url, 'w', transport_params={'session': session, 'multipart_upload_kwargs': {'ServerSideEncryption': 'aws:kms', 'SSEKMSKeyId': key}})
file.write(content)
file.close()