|
@@ -101,14 +101,17 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
|
|
|
@Override
|
|
|
public Map<String, Object> uploadImgMap(String engine, MultipartFile file) {
|
|
|
Map<String,Object> map = Maps.newHashMap();
|
|
|
- String bucketName;
|
|
|
- if(StringUtils.equals(devConfigApi.getValueByKey("SNOWY_ENVIRONMENT_CONFIG"),"linux")){
|
|
|
+ // 获取项目根路径
|
|
|
+ String bucketName = System.getProperty("user.dir");
|
|
|
+ // 定义目标文件夹路径(项目根路径下的 uploads 文件夹)
|
|
|
+ bucketName = bucketName + "/uploads";
|
|
|
+ /*if(StringUtils.equals(devConfigApi.getValueByKey("SNOWY_ENVIRONMENT_CONFIG"),"linux")){
|
|
|
//linux环境
|
|
|
bucketName = "/defaultUploadFolder"+"/hnzy/";
|
|
|
}else{
|
|
|
//windows环境
|
|
|
bucketName = devConfigApi.getValueByKey("SNOWY_FILE_LOCAL_FOLDER_FOR_WINDOWS")+"/hnzy";
|
|
|
- }
|
|
|
+ }*/
|
|
|
File localFile = new File(bucketName);
|
|
|
if(!localFile.exists()) {
|
|
|
localFile.mkdir();
|
|
@@ -117,8 +120,8 @@ public class DevFileServiceImpl extends ServiceImpl<DevFileMapper, DevFile> impl
|
|
|
File imgFile = new File(localPath);
|
|
|
try {
|
|
|
// 保存文件到本地
|
|
|
- //file.transferTo(imgFile);
|
|
|
- imgFile.createNewFile(); // 创建文件
|
|
|
+ file.transferTo(imgFile);
|
|
|
+ //imgFile.createNewFile(); // 创建文件
|
|
|
log.info("文件上传成功!文件保存路径:" + localPath);
|
|
|
String result = HttpRequest.post(devConfigApi.getValueByKey("SNOWY_FILE_PATH")).
|
|
|
form("groupName", "hnzy").
|