spring boot file upload size setting


Add configuration in application.properties :
spring.http.multipart.maxFileSize=50Mb
spring.http.multipart.maxRequestSize=50Mb

Control the size of the file submitted by the web, if the size exceeds, the request will not go to the background

	@Bean(name = "multipartResolver")
	public MultipartResolver multipartResolver() {
		CommonsMultipartResolver resolver = new CommonsMultipartResolver();
		resolver.setDefaultEncoding("UTF-8");
		resolver.setResolveLazily(true);
		resolve.setMaxInMemorySize(40960);
		resolver.setMaxUploadSize(10 * 1024 * 1024);// upload file size 10M 10*1024*1024
		return resolver;
	}

Control file size filtering from code.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326232326&siteId=291194637