I'm using AWS SAM to deploy locally my Lambda function and test it.
I'm creating a function that receives a multipart/form-data
body (includes a pdf file). When I do the request, lambda returns a 502 BAD GATEWAY
message, but if I send only the text attributes or text files (markdown, text, xml, html) instead of binary files (pdf, images, etc.) It works. Here's my code.
template.yml
...
PostRequest:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: com.demo.handlers.request.PostRequest
Runtime: java11
Description: Post a Request
MemorySize: 512
Timeout: 100
Events:
HttpPost:
Type: Api
Properties:
Path: /requests
Method: post
BinaryMediaTypes:
- "multipart/form-data"
...
I tried adding application/pdf
to the BinaryMediaTypes
property but It still not working.
Is there a workaround to manage this?
I know it's late, but I'm dropping what works for me in case someone land here and have the same issue.
...
Globals:
Api:
BinaryMediaTypes:
- "*~1*"
Resources:
PostRequest:
Type: AWS::Serverless::Function
Properties:
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.