Reputation: 749
I have a rest controller method that receive a multipart file parameter, I need to constraint the file size limit of it. I tried different optiones but it's not working yet for me. I´m using Apache Tomcat 8. I'm calling the rest method by a windows service.
Following the definition of the class and the method:
@Controller
public class MyClass{
...
}
@RequestMapping(value = "/path/method/param1/{param1}/param2/{param2}/",
method = RequestMethod.POST)
public ResponseEntity<String> method(DTO dto, @RequestParam("file") MultipartFile multipartFile){
...
}
Solutions tested:
<multipart-config> <max-file-size>52428800</max-file-size> <max-request-size>52428800</max-request-size> <file-size-threshold>0<</file-size-threshold> </multipart-config>
Adding maxPostSize and maxSwallowSize properties to the connector node in the server.xml file
Adding parameters of size to the .properties file
Adding the @MultipartConfig annotation in the controller class
Any idea or suggestions?
Upvotes: 4
Views: 1110
Reputation: 46
Check the spring-servlet.xml
file, maybe there is a created bean of the class org.springframework.web.multipart.commons.CommonsMultipartResolver
, it could be above of the rest of configurations or methods to handle this
Upvotes: 3