Compare commits
3 Commits
1940da7294
...
90f06480c8
Author | SHA1 | Date |
---|---|---|
|
90f06480c8 | 2 years ago |
|
a74f720c0b | 2 years ago |
|
08b235ad57 | 2 years ago |
@ -0,0 +1,30 @@
|
||||
package com.shxy.xymanager_common.bean;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.servlet.MultipartConfigElement;
|
||||
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class MultipartConfig {
|
||||
@Value("${spring.servlet.multipart.location}")
|
||||
private String fileTempDir;
|
||||
|
||||
@Bean
|
||||
MultipartConfigElement multipartConfigElement() {
|
||||
String os = System.getProperty("os.name");
|
||||
// 兼容windows
|
||||
if(os.toLowerCase().startsWith("win")){
|
||||
fileTempDir = "C:" + fileTempDir;
|
||||
}
|
||||
log.info("fileTempDir:{}", fileTempDir);
|
||||
MultipartConfigFactory factory = new MultipartConfigFactory();
|
||||
factory.setLocation(fileTempDir);
|
||||
return factory.createMultipartConfig();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue