Search in sources :

Example 1 with MultipartConfigFactory

use of org.springframework.boot.web.servlet.MultipartConfigFactory in project spring-boot by spring-projects.

the class MultipartProperties method createMultipartConfig.

/**
 * Create a new {@link MultipartConfigElement} using the properties.
 * @return a new {@link MultipartConfigElement} configured using there properties
 */
public MultipartConfigElement createMultipartConfig() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
    map.from(this.fileSizeThreshold).to(factory::setFileSizeThreshold);
    map.from(this.location).whenHasText().to(factory::setLocation);
    map.from(this.maxRequestSize).to(factory::setMaxRequestSize);
    map.from(this.maxFileSize).to(factory::setMaxFileSize);
    return factory.createMultipartConfig();
}
Also used : MultipartConfigFactory(org.springframework.boot.web.servlet.MultipartConfigFactory) PropertyMapper(org.springframework.boot.context.properties.PropertyMapper)

Example 2 with MultipartConfigFactory

use of org.springframework.boot.web.servlet.MultipartConfigFactory in project sinsim by WilsonHu.

the class FileUploadConfig method multipartConfigElement.

@Bean
public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    // 设置文件大小限制 ,超出设置页面会抛出异常信息,
    // 这样在文件上传的地方就需要进行异常信息的处理了;
    // KB,MB
    factory.setMaxFileSize("10MB");
    // / 设置总上传数据总大小
    factory.setMaxRequestSize("100MB");
    // factory.setLocation("路径地址");
    return factory.createMultipartConfig();
}
Also used : MultipartConfigFactory(org.springframework.boot.web.servlet.MultipartConfigFactory) Bean(org.springframework.context.annotation.Bean)

Example 3 with MultipartConfigFactory

use of org.springframework.boot.web.servlet.MultipartConfigFactory in project alien4cloud by alien4cloud.

the class Bootstrap method multipartConfigElement.

@Bean
public MultipartConfigElement multipartConfigElement(@Value("${upload.max_archive_size}") long maxUploadSize) {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    factory.setMaxRequestSize(maxUploadSize);
    factory.setMaxFileSize(maxUploadSize);
    return factory.createMultipartConfig();
}
Also used : MultipartConfigFactory(org.springframework.boot.web.servlet.MultipartConfigFactory) YamlPropertiesFactoryBean(org.springframework.beans.factory.config.YamlPropertiesFactoryBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with MultipartConfigFactory

use of org.springframework.boot.web.servlet.MultipartConfigFactory in project Spring-Family by Sierou-Java.

the class CommonConfig method multipartConfigElement.

@Bean
public MultipartConfigElement multipartConfigElement() {
    MultipartConfigFactory factory = new MultipartConfigFactory();
    factory.setMaxFileSize(1024L * 1024L * Integer.parseInt(UploadUtils.maxSize));
    return factory.createMultipartConfig();
}
Also used : MultipartConfigFactory(org.springframework.boot.web.servlet.MultipartConfigFactory) Bean(org.springframework.context.annotation.Bean)

Aggregations

MultipartConfigFactory (org.springframework.boot.web.servlet.MultipartConfigFactory)4 Bean (org.springframework.context.annotation.Bean)3 YamlPropertiesFactoryBean (org.springframework.beans.factory.config.YamlPropertiesFactoryBean)1 PropertyMapper (org.springframework.boot.context.properties.PropertyMapper)1 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)1