Handling Large File Uploads in Spring Boot REST API with MultipartFile
I'm currently implementing a REST API in Spring Boot (version 2.6.2) that allows users to upload large files using `MultipartFile`. However, I'm working with issues with `javax.servlet.ServletException: Multipart file size exceeds limit` when attempting to upload files over 5 MB. I’ve tried adjusting the configuration settings in my `application.properties` file by adding: ```properties spring.servlet.multipart.max-file-size=10MB spring.servlet.multipart.max-request-size=10MB ``` Despite this, I'm still receiving the same behavior message. I also attempted to set these properties programmatically in a configuration class: ```java import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.commons.CommonsMultipartResolver; @Configuration public class MultipartConfig { @Bean public MultipartResolver multipartResolver() { CommonsMultipartResolver resolver = new CommonsMultipartResolver(); resolver.setMaxUploadSize(10485760); // 10MB return resolver; } } ``` However, this did not resolve the scenario either. I’m also using Spring Security (5.6.0) for authentication, and I suspect there might be some constraints applied during the file upload process. My current endpoint for handling uploads looks like this: ```java @PostMapping("/upload") public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file) { // some logic to save the file return ResponseEntity.ok("File uploaded successfully!"); } ``` Could there be any additional configurations or settings I need to be aware of when dealing with larger file uploads? Or is there a recommended best practice for handling such scenarios in a Spring Boot application? Any help would be greatly appreciated! I'm developing on Linux with Java. Any ideas what could be causing this?