1

How to upload large files in spring boot gradle?

@Bean
public CommonsMultipartResolver commonsMultipartResolver() {
    final CommonsMultipartResolver commonsMultipartResolver = new CommonsMultipartResolver();
    commonsMultipartResolver.setMaxUploadSize(-1);
    return commonsMultipartResolver;
}

@Bean
public FilterRegistrationBean multipartFilterRegistrationBean() {
    final MultipartFilter multipartFilter = new MultipartFilter();
    final FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(multipartFilter);
    filterRegistrationBean.addInitParameter("multipartResolverBeanName", "commonsMultipartResolver");
    return filterRegistrationBean;
}

When I gave above code then upload only large files. Not upload byte and kb files.

4

2 回答 2

0

您可以在 application.yml 或 properties 中轻松配置 multipart maxFileSize。

  multipart:
     maxFileSize: 30MB
于 2016-06-03T05:16:23.160 回答
0

您可以设置 2 个属性:

multipart.max-file-size=1Mb

最大文件大小。值可以使用后缀“MB”或“KB”来表示兆字节或千字节大小。

multipart.max-request-size=10Mb

最大请求大小。值可以使用后缀“MB”或“KB”来表示兆字节或千字节大小。

您可以在http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html找到所有属性的列表

于 2016-06-03T05:18:09.877 回答