generated from root/miduo_server
文件上传修改默认路径
parent
e63b01758f
commit
d568493992
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue