Skip to content

MultipartFile is Null in @ModelAttribute with Spring Boot 3.3.4 but Works in 3.2.4 #42883

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

Closed
kkong101 opened this issue Oct 25, 2024 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@kkong101
Copy link

Title:
MultipartFile is Null in @ModelAttribute with Spring Boot 3.3.4 but Works in 3.2.4

Description:

When upgrading from Spring Boot version 3.2.4 to 3.3.4, the MultipartFile parameter in the controller method becomes null. This issue does not occur in version 3.2.4, where the file is correctly received. There are no restrictions on file size or other related configurations.

Steps to Reproduce

  1. Controller Setup:

    @PostMapping("/users")
    fun insertTryOnFace(
        @ModelAttribute imageFile: MultipartFile,
        @ModelAttribute gender: Gender,
    ) {
        // Implementation
    }
  2. Send a POST Request:

    • Endpoint: /users
    • Method: POST
    • Content-Type: multipart/form-data
    • Parameters:
      • imageFile: [Attach a file]
      • gender: [Provide appropriate value]
  3. Observe the Behavior:

    • Spring Boot 3.3.4: imageFile is null.
    • Spring Boot 3.2.4: imageFile is correctly received.

Expected Behavior
The MultipartFile should be correctly populated with the uploaded file data regardless of the Spring Boot version, provided there are no size or configuration restrictions.

Actual Behavior
In Spring Boot 3.3.4, the imageFile parameter is null when handling the POST request, whereas it works as expected in 3.2.4.

Additional Information

  • Spring Boot Versions:
    • Affected: 3.3.4
    • Working: 3.2.4
  • File Size Limits: No restrictions set; default configurations are used.
  • Environment: �MacOs
  • Relevant Dependencies: jvmTarget 17, kotlinVersion 2.0.21, io.spring.dependency-management 1.1.6

Request
Looking for assistance or a fix to ensure that MultipartFile is correctly populated in Spring Boot 3.3.4 when using @ModelAttribute.

@wilkinsona
Copy link
Member

Your previous issue was intentionally moved from Spring Boot to Spring Framework as that's what @bclozel believes that the problem lies. Closing in favor of spring-projects/spring-framework#33791.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants