AttributeError: 'dict' object has no attribute 'append' boto3 generate presigned post
AttributeError: 'dict' object has no attribute 'append' boto3 generate presigned post
我正在尝试使用 boto3 创建预签名 post 签名和表单。
key = str(venuepk) +'/' + str(samplemenuid) + '/${filename}'
fields = {'acl': 'public-read',
'content-type': 'application/PDF'}
conditions = {'acl': 'public-read',
'content-type': 'application/PDF'}
s3=boto3.client('s3')
post = s3.generate_presigned_post(
Bucket = AWS_UPLOAD_BUCKET,
Key = key,
Fields = fields,
Conditions=conditions
)
return Response({
'url': post['url'],
'fields': post['fields'],
'samplemenupk': samplemenuid
})
按照文档进行了 'T'
https://boto3.readthedocs.io/en/latest/guide/s3.html#generating-presigned-posts
但我不断收到此错误:
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/local/lib/python2.7/site-packages/rest_framework/views.py", line 491, in dispatch
response = handler(request, *args, **kwargs)
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/suitsandtables/venues/views.py", line 142, in post
Conditions=conditions
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/local/lib/python2.7/site-packages/botocore/signers.py", line 698, in generate_presigned_post
conditions.append({'bucket': bucket})
AttributeError: 'dict' object has no attribute 'append'
错误是因为python 字典没有附加方法。条件值应该是如下所示的列表
conditions = [
{"acl": "public-read"},
["content-length-range", 10, 100]
]
它实际上显示为 documentation
中的列表
我正在尝试使用 boto3 创建预签名 post 签名和表单。
key = str(venuepk) +'/' + str(samplemenuid) + '/${filename}'
fields = {'acl': 'public-read',
'content-type': 'application/PDF'}
conditions = {'acl': 'public-read',
'content-type': 'application/PDF'}
s3=boto3.client('s3')
post = s3.generate_presigned_post(
Bucket = AWS_UPLOAD_BUCKET,
Key = key,
Fields = fields,
Conditions=conditions
)
return Response({
'url': post['url'],
'fields': post['fields'],
'samplemenupk': samplemenuid
})
按照文档进行了 'T'
https://boto3.readthedocs.io/en/latest/guide/s3.html#generating-presigned-posts
但我不断收到此错误:
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/local/lib/python2.7/site-packages/rest_framework/views.py", line 491, in dispatch
response = handler(request, *args, **kwargs)
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/suitsandtables/venues/views.py", line 142, in post
Conditions=conditions
File "/home/rickus/Documents/softwareProjects/211hospitality/suitsandtables/backend/virtualsuits/local/lib/python2.7/site-packages/botocore/signers.py", line 698, in generate_presigned_post
conditions.append({'bucket': bucket})
AttributeError: 'dict' object has no attribute 'append'
错误是因为python 字典没有附加方法。条件值应该是如下所示的列表
conditions = [
{"acl": "public-read"},
["content-length-range", 10, 100]
]
它实际上显示为 documentation
中的列表