Commit fd0f480f by fsn

头像上传完善

parent 85932501
...@@ -3,6 +3,8 @@ package com.stylefeng.guns.config.properties; ...@@ -3,6 +3,8 @@ package com.stylefeng.guns.config.properties;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.File;
import static com.stylefeng.guns.core.util.ToolUtil.getTempPath; import static com.stylefeng.guns.core.util.ToolUtil.getTempPath;
import static com.stylefeng.guns.core.util.ToolUtil.isEmpty; import static com.stylefeng.guns.core.util.ToolUtil.isEmpty;
...@@ -22,11 +24,23 @@ public class GunsProperties { ...@@ -22,11 +24,23 @@ public class GunsProperties {
private String fileUploadPath; private String fileUploadPath;
private Boolean haveCreatePath = false;
public String getFileUploadPath() { public String getFileUploadPath() {
//如果没有写文件上传路径 //如果没有写文件上传路径,保存到临时目录
if(isEmpty(fileUploadPath)){ if(isEmpty(fileUploadPath)){
return getTempPath(); return getTempPath();
}else{ }else{
//判断有没有结尾符,没有得加上
if(!fileUploadPath.endsWith(File.separator)){
fileUploadPath = fileUploadPath + File.separator;
}
//判断目录存不存在,不存在得加上
if(haveCreatePath == false){
File file = new File(fileUploadPath);
file.mkdirs();
haveCreatePath = true;
}
return fileUploadPath; return fileUploadPath;
} }
} }
......
################### guns项目独有的配置 ################### ################### guns项目独有的配置 ###################
guns: guns:
kaptcha-open: false #是否开启登录时验证码 (true/false) kaptcha-open: false #是否开启登录时验证码 (true/false)
file-upload-path: #file-upload-path: d:/tmp #文件上传目录(不配置的话为java.io.tmpdir目录)
################### 项目启动端口 ################### ################### 项目启动端口 ###################
server: server:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment