使用sam cli生成和启动无服务器功能的api,我想在请求正文中发布表单数据文件。不幸的是,我收到“消息”:“内部服务器错误”。
想法是将模板更改为接受aws文档所指向的二进制文件,但是没有任何效果。
这是我的模板文件(添加了对二进制媒体类型的支持):
AWSTemplateFormatVersion:'2010-09-09' 转换:AWS :: Serverless-2016-10-31 说明:> sam-app
Sample SAM Template for sam-app
全球: api: #通过API发送/接收二进制数据 BinaryMediaTypes: -图片〜1jpg
Function:
Timeout: 3
资源:
HelloWorldFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: hello_world/
Handler: app.lambdaHandler
Runtime: nodejs8.10
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
PARAM1: VALUE
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
Path: /hello
Method: post
输出:
HelloWorldApi:
Description: "API Gateway endpoint URL for Prod stage for Hello World function"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
HelloWorldFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn