5

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!

  • Any luck with this so far? I'm struggling with it, too. – tobiasbayer Jul 16 '19 at 11:31
  • 1
    No, I ended up just scrapping it and sticking with spark java and the `aws-serverless-java-container-spark` proxy. – casey gerstle Jul 17 '19 at 14:58
  • I am also stuck at this point and the worst part is that I cannot switch to spark proxy. Has anyone looked into this issue? Should this be highlighted to the Micronaut team? – Pulkit Gupta Sep 28 '19 at 09:30
  • Unfortunately the same for me. On the 1.2.5 Micronaut version. I've posted a question in their Gitter, but haven't got any response yet... and frankly speaking I don't believe we ever will get one :) – Stanislau Oct 30 '19 at 21:50
  • This question shows an example of handling a file upload using Multipart-Form-Data: https://stackoverflow.com/questions/67708441/micronaut-multipart-upload-error-required-argument-completedfileupload-not – Gavin Oct 14 '22 at 11:46

0 Answers0