diff --git a/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java index 78905cf72..71a6112cd 100644 --- a/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/file/service/impl/FiletransferServiceImpl.java @@ -55,10 +55,10 @@ public class FiletransferServiceImpl implements IFiletransferService { Uploader uploader = new ChunkUploaderFactory().getUploader(uploadFile); checkParams(uploadFileDTO, uploadFile); List uploadFileList = uploader.upload(request, PathUtil.getBasePath() + "/"); - minioUtils.uploadBySameName(uploadFile.getUrl(), false); for (int i = 0; i < uploadFileList.size(); i++) { uploadFile = uploadFileList.get(i); if (uploadFile.getSuccess() == 1) { + minioUtils.uploadBySameName(uploadFile.getUrl(), false); ProjectFile userFile = new ProjectFile(); userFile.setExtendName(uploadFile.getFileType()); userFile.setFileName(uploadFile.getFileName()); diff --git a/src/main/java/com/zhgd/xmgl/util/MinioUtils.java b/src/main/java/com/zhgd/xmgl/util/MinioUtils.java index a93e767aa..681b6ff1f 100644 --- a/src/main/java/com/zhgd/xmgl/util/MinioUtils.java +++ b/src/main/java/com/zhgd/xmgl/util/MinioUtils.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpUtil; import cn.xuyanwu.spring.file.storage.FileInfo; import cn.xuyanwu.spring.file.storage.FileStorageService; +import com.gexin.fastjson.JSON; import com.zhgd.xmgl.config.MinIoClientConfig; import com.zhgd.xmgl.constant.Cts; import io.minio.*; @@ -261,7 +262,7 @@ public class MinioUtils { minioClient.removeObject(removeObjectArgs); } catch (Exception e) { log.error("minio remove file error. pathUrl:{}", path); - e.printStackTrace(); + log.error("", e); } } @@ -324,11 +325,15 @@ public class MinioUtils { fileName = StringUtils.substringAfterLast(path, "/"); savePath = StringUtils.substringBeforeLast(path, "/"); } - FileInfo fileInfo = fileStorageService.of(PathUtil.getBasePath() + "/" + path) + String url = PathUtil.getBasePath() + "/" + path; + String savePath1 = savePath != null ? savePath + "/" : ""; + log.info("上传minio文件-路径:{},savePath1:{},saveFilename:{}", url, savePath1, fileName); + FileInfo fileInfo = fileStorageService.of(url) .setPlatform(Cts.MINIO_1) //使用指定的存储平台 - .setPath(savePath != null ? savePath + "/" : "") + .setPath(savePath1) .setSaveFilename(fileName) .upload(); + log.info("上传minio文件:{}", JSON.toJSONString(fileInfo)); } }