Search code examples
javamultipartform-datajava-11multipartfile

Process MultipartFile in serverless application on java11 without spring


I need to develop the severless application using java11 without spring. In this application i need to open an endpoint where the consumer is multipart/form-data. I know in spring we have a MultipartFile class using which we can grab the object and use it but i want to know how to do it without spring. After that i need to upload that file in amazon S3.
I am using Amazon Api gateway to expose the endpoint and amazon s3 for storage.


Solution

  • Note that on the way to your Serverless Java Lambda the AWS ApiGateway will transform your request into JSON for passing through to Lambda.

    To get this to work for multipart form you need to define multipart/form-data as a binary media type for your API and proxy the payload directly to a Lambda function.

    This is how you implement the Lambda in Java to consume the resulting payload.

    No Spring in sight. Just apache commons and aws stuff.