【发布时间】:2019-12-21 06:48:39
【问题描述】:
我正在通过 lambda 将图像上传到 s3,一切正常,没有错误,但 API Gateway 的响应是 500 Internal Server Error。
我按照本教程配置了我的 api-gateway:Binary Support for API Integrations with Amazon API Gateway。
我的 lambda 接收到 base64Image,解码并成功上传到 s3。
这是我的 lambda 代码:
def upload_image(event, context):
s3 = boto3.client('s3')
b64_image = event['base64Image']
image = base64.b64decode(b64_image)
try:
with io.BytesIO(image) as buffer_image:
buffer_image.seek(0)
s3.upload_fileobj(buffer_image, 'MY-BUCKET', 'image')
return {'status': True}
except ClientError as e:
return {'status': False, 'error': repr(e)}
这是我收到的: { “消息”:“内部服务器错误” },带有 500 状态码。
Obs:我没有使用 lambda 代理集成。
【问题讨论】:
-
你是如何导入boto3的?您的项目环境中是否包含 boto3?
-
是的,我的项目中包含了 boto3,并且我已经测试了我的 lambda 隔离,它运行良好。
标签: amazon-web-services amazon-s3 aws-lambda aws-api-gateway