@RequestBody MultipartFile[] submissions

should be

@RequestParam("file") MultipartFile[] submissions

The files are not the request body, they are part of it and there is no built-in HttpMessageConverter that can convert the request to an array of MultiPartFile.

You can also replace HttpServletRequest with MultipartHttpServletRequest, which gives you access to the headers of the individual parts.

Answer from a better oliver on Stack Overflow
🌐
Baeldung
baeldung.com › home › spring › spring boot › multipart request handling in spring
Multipart Request Handling in Spring | Baeldung
June 24, 2025 - In this article, we learned how to effectively handle multipart requests in Spring Boot. Initially, we sent multipart form data using a model attribute.
Discussions

Spring Boot: post and process multipart/form-data request with multiple body parts - Stack Overflow
I have the following endpoint that processes the multipart/form-data requests: @RequestMapping(value = "/test", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity More on stackoverflow.com
🌐 stackoverflow.com
November 18, 2019
Spring Boot controller - Upload Multipart and JSON to DTO
I had created a similar thing using pure JS and Spring Boot. Here is the Repo. I'm sending an User object as JSON and a File as part of the multipart/form-data request. ... @RestController public class FileUploadController { @RequestMapping(value = "/upload", method = RequestMethod.POST, consumes ... More on stackoverflow.com
🌐 stackoverflow.com
java - Spring boot - method 'POST' is not supported (multipart/form-data) - Stack Overflow
I'm trying to send through multipart/form-data a post request from my products controller, where I upload a file of images and information of my product in json @RestController @CrossOrigin(origi... More on stackoverflow.com
🌐 stackoverflow.com
java - Upload multipart/form-data file in Spring boot and REST API - Stack Overflow
16 Spring boot Multipart file upload as part of json body · 2 POST Request to upload multipart file in Spring Boot More on stackoverflow.com
🌐 stackoverflow.com
🌐
Spring
spring.io › guides › gs › uploading-files
Getting Started | Uploading Files
spring.servlet.multipart.max-request-size is set to 128KB, meaning total request size for a multipart/form-data cannot exceed 128KB. You want a target folder to which to upload files, so you need to enhance the basic UploadingFilesApplication class that Spring Initializr created and add a Boot CommandLineRunner to delete and re-create that folder at startup.
🌐
Medium
medium.com › @AlexanderObregon › multipart-form-parsing-in-spring-boot-with-mixed-data-and-files-d4db94bf6b05
Multipart Form Parsing in Spring Boot with Mixed Data and Files
August 17, 2025 - Spring MVC builds on top of this by allowing you to declare parameters in controller methods that match the form field names, making file and JSON handling feel almost automatic. Here’s a simple example where the JSON part is retrieved as text and manually deserialized: @RestController public class ProfileController { @PostMapping(path = "/profiles", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public String uploadProfile( @RequestParam("userData") String userData, @RequestParam("avatar") MultipartFile avatar) throws IOException { ObjectMapper mapper = new ObjectMapper(); UserProfile profile = mapper.readValue(userData, UserProfile.class); return "Received profile for " + profile.getFirstName() + " with file size " + avatar.getSize(); } }
🌐
GitHub
github.com › datnguyen293 › post-multipart-form-data-with-json-resttemplate
GitHub - datnguyen293/post-multipart-form-data-with-json-resttemplate: Using Spring Boot RestTemplate to post form multipart/form-data with JSON field · GitHub
Using Spring Boot RestTemplate to post a form with file and json data to an endpoint. Normally if you only set the Content-Type of the post request to MULTIPART_FORM_DATA is not enough.
Author   datnguyen293
🌐
BezKoder
bezkoder.com › home › spring boot file upload example with multipart file
Spring Boot File upload example with Multipart File - BezKoder
February 4, 2024 - When hitting postman request when you enter key in body -> form/data and hover over inside key box then you will see File option in addition to text. Select File option and choose a file and run the program it will work as expected. i am getting ...
🌐
Medium
medium.com › techpanel › multipartfile-with-springboot-d4901ee3e77d
MultipartFile with SpringBoot. This article explains two use cases of… | by Aakash Sorathiya | TechPanel | Medium
July 22, 2023 - @PostMapping(value = "/uploadFile", ... ResponseEntity<>("success", HttpStatus.OK); } PostMapping annotation is used to represent that uploadFile handles HTTP POST requests for the given URI....
Find elsewhere
🌐
Baeldung
baeldung.com › home › spring › spring web › spring mvc › file upload with spring mvc
Uploading Files with Spring MVC | Baeldung
November 26, 2025 - Regardless of the upload handling configuration we have chosen, we need to set the encoding attribute of the form to multipart/form-data. This lets the browser know how to encode the form: <form:form method="POST" action="/spring-mvc-xml/uploadFile" ...
🌐
Medium
medium.com › 12-developer-labors › spring-boot-file-upload-via-rest-controller-6dcc7e5d6e54
Spring, file upload via multipart/form-data | by piotr szybicki | 12 developer labors | Medium
December 22, 2018 - Two things filename (that one is not so important, I told you that append accepts 3 parameters filename is that third). And much more important Content-Type. Every entry in multi-part form, during processing by the servlet , becomes a MultipartFile.
🌐
Stack Overflow
stackoverflow.com › questions › 58918066 › spring-boot-post-and-process-multipart-form-data-request-with-multiple-body-par
Spring Boot: post and process multipart/form-data request with multiple body parts - Stack Overflow
November 18, 2019 - I have the following endpoint that processes the multipart/form-data requests: @RequestMapping(value = "/test", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity
Top answer
1 of 12
93

Yes, you can simply do it via wrapper class.

1) Create a Class to hold form data:

public class FormWrapper {
    private MultipartFile image;
    private String title;
    private String description;
}

2) Create an HTML form for submitting data:

<form method="POST" enctype="multipart/form-data" id="fileUploadForm" action="link">
    <input type="text" name="title"/><br/>
    <input type="text" name="description"/><br/><br/>
    <input type="file" name="image"/><br/><br/>
    <input type="submit" value="Submit" id="btnSubmit"/>
</form>

3) Create a method to receive form's text data and multipart file:

@PostMapping("/api/upload/multi/model")
public ResponseEntity<?> multiUploadFileModel(@ModelAttribute FormWrapper model) {
    try {
        // Save as you want as per requiremens
        saveUploadedFile(model.getImage());
        formRepo.save(mode.getTitle(), model.getDescription());
    } catch (IOException e) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }

    return new ResponseEntity("Successfully uploaded!", HttpStatus.OK);
}

4) Method to save file:

private void saveUploadedFile(MultipartFile file) throws IOException {
    if (!file.isEmpty()) {
        byte[] bytes = file.getBytes();
        Path path = Paths.get(UPLOADED_FOLDER + file.getOriginalFilename());
        Files.write(path, bytes);
    }
}
2 of 12
49

I had created a similar thing using pure JS and Spring Boot. Here is the Repo. I'm sending an User object as JSON and a File as part of the multipart/form-data request.

The relevant snippets are below

The Controller code

@RestController
public class FileUploadController {

    @RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = { "multipart/form-data" })
    public void upload(@RequestPart("user") @Valid User user,
            @RequestPart("file") @Valid @NotNull @NotBlank MultipartFile file) {
            System.out.println(user);
            System.out.println("Uploaded File: ");
            System.out.println("Name : " + file.getName());
            System.out.println("Type : " + file.getContentType());
            System.out.println("Name : " + file.getOriginalFilename());
            System.out.println("Size : " + file.getSize());
    }

    static class User {
        @NotNull
        String firstName;
        @NotNull
        String lastName;

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        @Override
        public String toString() {
            return "User [firstName=" + firstName + ", lastName=" + lastName + "]";
        }

    }
}

The HTML and JS code

<html>    
<head>
    <script>
        function onSubmit() {

            var formData = new FormData();

            formData.append("file", document.forms["userForm"].file.files[0]);
            formData.append('user', new Blob([JSON.stringify({
                "firstName": document.getElementById("firstName").value,
                "lastName": document.getElementById("lastName").value
            })], {
                    type: "application/json"
                }));
            var boundary = Math.random().toString().substr(2);
            fetch('/upload', {
                method: 'post',
                body: formData
            }).then(function (response) {
                if (response.status !== 200) {
                    alert("There was an error!");
                } else {
                    alert("Request successful");
                }
            }).catch(function (err) {
                alert("There was an error!");
            });;
        }
    </script>
</head>

<body>
    <form name="userForm">
        <label> File : </label>
        <br/>
        <input name="file" type="file">
        <br/>
        <label> First Name : </label>
        <br/>
        <input id="firstName" name="firstName" />
        <br/>
        <label> Last Name : </label>
        <br/>
        <input id="lastName" name="lastName" />
        <br/>
        <input type="button" value="Submit" id="submit" onclick="onSubmit(); return false;" />
    </form>
</body>    
</html>
🌐
Perficient Blogs
blogs.perficient.com › home › requestbody and multipart on spring boot
RequestBody and Multipart on Spring Boot / Blogs / Perficient
April 10, 2026 - Step 7: Upload the Multipart file and POJO in Postman. Now, Test the response using Postman by adding the body parameters and values as below. ... Now let us attach the sample file which we need to pass in the request. ... Looks like all done and dusted…!!! You may get the source code from here: PraseelaRadhakrishnan/Spring-Boot/Spring-Boot-Upload
🌐
Spring
docs.spring.io › spring-framework › reference › web › webmvc › mvc-controller › ann-methods › multipart-forms.html
Multipart :: Spring Framework
POST /someUrl Content-Type: multipart/mixed --edt7Tfrdusa7r3lNQc79vXuhIIMlatb7PQg7Vp Content-Disposition: form-data; name="meta-data" Content-Type: application/json; charset=UTF-8 Content-Transfer-Encoding: 8bit { "name": "value" } --edt7Tfrdusa7r3lNQc79vXuhIIMlatb7PQg7Vp Content-Disposition: form-data; name="file-data"; filename="file.properties" Content-Type: text/xml Content-Transfer-Encoding: 8bit ...
🌐
Stack Overflow
stackoverflow.com › questions › 75631512 › spring-boot-method-post-is-not-supported-multipart-form-data
java - Spring boot - method 'POST' is not supported (multipart/form-data) - Stack Overflow
Change your @PostMapping(MediaType.MULTIPART_FORM_DATA_VALUE) because putting the media type there will actually map the URL to /product/multipart/form-data and not /product/
🌐
Spring
docs.spring.io › spring-framework › reference › web › webflux › controller › ann-methods › multipart-forms.html
Multipart Content :: Spring Framework
POST /someUrl Content-Type: multipart/mixed --edt7Tfrdusa7r3lNQc79vXuhIIMlatb7PQg7Vp Content-Disposition: form-data; name="meta-data" Content-Type: application/json; charset=UTF-8 Content-Transfer-Encoding: 8bit { "name": "value" } --edt7Tfrdusa7r3lNQc79vXuhIIMlatb7PQg7Vp Content-Disposition: form-data; name="file-data"; filename="file.properties" Content-Type: text/xml Content-Transfer-Encoding: 8bit ...
🌐
Medium
blog.classkick.com › using-multipart-form-data-with-spring-boot-3216d67ae2b9
Using Multipart Form Data with Spring Boot | by Colin Shevlin | Classkick
October 5, 2016 - Since we planned to handle both audio and image data, using multipart form data was an obvious choice. Multipart form data was introduced to solve the problem of an http form that includes a file.
🌐
Medium
medium.com › @AlexanderObregon › breaking-down-the-multipart-upload-process-within-spring-boot-9ad27fb4138f
Breaking Down the Multipart Upload Process within Spring Boot
May 9, 2025 - POST /upload HTTP/1.1 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary ------WebKitFormBoundary Content-Disposition: form-data; name="username" alex_obregon ------WebKitFormBoundary Content-Disposition: form-data; name="file"; filename="readme.txt" Content-Type: text/plain This is the content of the file. ------WebKitFormBoundary-- You’ve got raw bytes, but there’s structure in there. The content-disposition tells you what kind of field it is, and the boundary marks the edges. Spring Boot takes care of all this with multipart support built into the framework.
🌐
Reddit
reddit.com › r/springsource › spring boot, multipart/form-data and nested data structures
r/springsource on Reddit: Spring Boot, multipart/form-data and nested data structures
January 28, 2020 -

So I’ve been googling this for hours, and my colleague, the backend developer on my team, has as well; how do we parse a multipart/form-data payload looking like this?

name: Overridden file name
concerns: 5211622c-11e9-45cd-ac1f-cde09c864a51
shares[0].id: c0b1697e-9639-409a-b09d-9fd7334f987f
shares[1].id: 5211622c-11e9-45cd-ac1f-cde09c864a51
file: (binary)

Obviously, what we want to parse this to in Spring, is

{
    name: "Overridden file name",
    concerns: "5211622c-11e9-45cd-ac1f-cde09c864a51",
    shares: [
        { id: "c0b1697e-9639-409a-b09d-9fd7334f987f" },
        { id: "5211622c-11e9-45cd-ac1f-cde09c864a51" }
    ],
    file: ...
}

The values of fields with static names are readily accessible, whereas shares isn’t a name in the payload; there are only separate values with names that start with shares, followed by the nested structure annotations.

Now, here’s the twist: I really don’t want to encode this nested data structure as a JSON string in my web frontend, as I’m using a generic form field component which is also in use in forms without files, ie. forms where the payload is serialized and submitted as JSON. The serializer in use in these cases understands annotations such as brackets and dots in input names and converts values into corresponding data structures (which is a really common thing in the JavaScript eco system). Heck, most of them even distinguish between numbers and strings inside brackets, and either give you an array or an object, so there’s usually even no need for dot notation.

Is there a [simple?] way to achieve parsing such multipart payloads into meaningful, structured data in Spring?

🌐
Jungbin's Blog
blog.jungbin.kim › spring › 2018 › 09 › 11 › springboot-multipart-request.html
Handling Multipart/form-data on Spring Boot 2 - Jungbin’s Blog
September 11, 2018 - @RequestMapping(path = "/files", method = RequestMethod.POST, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) public @ResponseBody ResponseEntity<String> add( @RequestParam("file") MultipartFile file, @RequestParam("name") String name, @RequestParam("brand") String brand) { System.out.println(file.getOriginalFilename() + "\n" + name + "\n" + brand); return new ResponseEntity<>("Created", HttpStatus.OK); }