Skip to content

feat(function-aws-api-proxy): add multipart/form-data support to ApiGatewayServletRequest #2317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 4.9.x
Choose a base branch
from

Conversation

nanodeath
Copy link

@nanodeath nanodeath commented Mar 21, 2025

Hi there! This is a change to add support for multipart form uploads, e.g. file uploads. The Serverless Function mode already supports file uploads, but if you want to use them in your controllers (Application mode), we need something like this.

Previously, this module was using the query string decoder on the body for multipart uploads, which isn't right -- multipart form bodies have their own crazy syntax.

This adds support to the base ApiGatewayServletRequest for multipart/form-data requests and argument bindings for:

  • @Part String name (binding to a part of name name)
  • @Part("foo") String name
  • @Part("file") CompletedFileUpload file

This does NOT add support for:

  • Streaming file uploads (which I'm not sure we can easily support anyway)

This change is currently missing:

  • Unit tests for the new classes
  • Integration tests (?) for handling API Gateway events containing file uploads.
    • If this is something we need, I'd appreciate any pointers you have on how to implement this.

I've created a simple test project that can verify this works and can provide if there's interest.

Looking for feedback and direction on things that need to be implemented before this can be merged. Thanks!

  • Feedback on thread safety
  • Feedback on whether there's a better way to store file uploads -- they don't exactly fit in the parameters map, which is a String map.
  • Feedback on class visibility, package structure, annotations

Closes #270.

…atewayServletRequest

This adds support for parsing multipart/form-data in AWS API Gateway proxy requests.
The implementation handles boundary extraction, part parsing, and field name extraction
while maintaining compatibility with existing form handling.

Co-Authored-By: Claude <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Mar 21, 2025

CLA assistant check
All committers have signed the CLA.

@graemerocher
Copy link
Contributor

Nice! Will review next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for multipart upload for API Gateway
3 participants