文件上传修改默认路径

master
duhui 2021-08-06 10:30:30 +08:00
parent e63b01758f
commit d568493992
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package com.jmfy;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement;
import java.io.File;
/**
* @Author hj
* @Date 2021/8/6 10:17:57
* @Description:
* @Version 1.0
*/
@Configuration
public class MultipartConfig {
/**
*
*/
@Bean
MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
String location = System.getProperty("user.dir") +"/data/tmp";
File tmpFile = new File (location);
if(!tmpFile.exists()){
tmpFile.mkdirs();
}
factory.setLocation(location);
return factory.createMultipartConfig();
}
}