I'm using micronaut
1.1.0.RC2
and micronaut-function-aws-api-proxy
1.1.0.RC3
within an AWS API Gateway proxy to a Kotlin Lambda function. The micronaut aws api proxy works fine for all of my API functions except for the file upload route. Class and route definition look something like this:
@Controller("/things/{id}/attachments")
class AttachmentController {
@Post(consumes = [MediaType.MULTIPART_FORM_DATA])
fun post(request: HttpRequest<Any>, id: Int, file: CompletedFileUpload): Attachment? {
...
}
}
Running locally, this works fine. But, when I use it via API Gateway and Lambda, I keep getting the follow error:
ERROR c.a.s.p.AwsProxyExceptionHandler Called exception handler for:
io.micronaut.web.router.exceptions.UnsatisfiedRouteException: Required argument [CompletedFileUpload file] not specified
at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:279)
at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)
...
Again, if I run the micronaut application locally and hit the API directly (no micronaut AWS proxy), it functions perfectly. But, when I deploy it to AWS, there seems to be an issue with the micronaut aws proxy that doesn't correctly parse out the multipart form-data.
I do have multipart/form-data
set as a binary media type on the API Gateway. I have tried using both the CompletedFileUpload
type and the StreamingFileUpload
type as described in the main micronaut docs (https://docs.micronaut.io/1.1.0.RC2/guide/index.html) with the same results.
And for what it's worth, I have a different implementation of this same thing using the AWS spark proxy (aws-serverless-java-container-spark) and it functions correctly.
To test, I'm running this curl command:
curl -X POST https://<host>/things/42/attachments -H 'content-type: multipart/form-data' -F file=@/path/to/file.png
Has anyone else had any luck with this? Is it just not supported at this point by the micronaut api gateway proxy? Any help is appreciated!