SpringBoot设置MultipartFile文件大小限制


原文链接:https://blog.csdn.net/qq_36514766/article/details/102500310

package com.gdd.videos.mini_api.common;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;

import javax.servlet.MultipartConfigElement;
import java.io.IOException;

/**
* @author zhangh
* @version V1.0.0
* @projectName parent
* @title IndexSwaggerConfig
* @package com.gdd.videos.mini_api.common
* @date 2019/9/11 15:19
* @explain 项目启动时默认打开swagger页面
*/
@Configuration
public class IndexSwaggerConfig {

/**
* 配置文件上传大小
*/
@Bean
public MultipartConfigElement multipartConfigElement(){
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小 10M
factory.setMaxFileSize("10240KB");
/// 总上传数据大小 10M
factory.setMaxRequestSize("10240KB");
return factory.createMultipartConfig();
}

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM