SpringBoot's @MultipartConfig maxFileSize not taking effect

后端 未结 7 1527
野性不改
野性不改 2021-02-02 07:52

I have a controller with a MultipartConfig annotation (a snippet of which is show below):

@RestController
@RequestMapping(\"packages\")
@MultipartCo         


        
7条回答
  •  时光取名叫无心
    2021-02-02 08:32

    If you just want to control the multipart properties, you can use multipart.max-file-size and multipart.max-request-size properties. For example, you could raise the max size to 100Mb by adding following piece of configurations in your application.properties file:

    multipart.max-file-size=100MB
    multipart.max-request-size=100MB
    

    Values can use the suffixed MB or KB to indicate a Megabyte or Kilobyte size.

    Under the hood, Spring Boot will create a MultipartConfigElement based on MultipartProperties and that MultipartConfigElement will be used in Servlet registration, as stated in Spring MVC documentation. You can take a look at MultipartAutoConfiguration and DispatcherServletConfiguration and Checkout Spring Boot documentation for more information.

提交回复
热议问题