我有以下脚本,可以将文件上传到s3存储桶中:
import boto3
from botocore.config import Config
s3_conf = {
'bucket': 'the_bucketr',
'folder': 'cohort',
'config': Config(
region_name = 'eu-central-1',
signature_version = 'v4',
retries = {
'max_attempts': 10,
'mode': 'standard'
}),
'aws_access_key_id':'^SOKE_KEY^',
'aws_secret_access_key':'^NOT_TELLING_U^'
}
s3_client = boto3.client('s3',
config=s3_conf['config'],
aws_access_key_id=s3_conf['aws_access_key_id'],
aws_secret_access_key=s3_conf['aws_secret_access_key']
)
s3_client.upload_file('loremIpsum.txt',s3_conf['bucket'],'loremUpsum.txt')
但我得到了错误:
Failed to upload loremIpsum.txt to the_bucketr/loremIpsum.txt: An error occurred (InvalidRequest) when calling the CreateMultipartUpload operation: Missing required header for this request: x-amz-content-sha256
你知道我该怎么解决这个问题吗?
为了绕过问题,您可以更改行
signature_version = 'v4',
进入:
signature_version = 's3v4',
它将像一台润滑良好的战争机器一样工作。