上传bug修复

This commit is contained in:
guoshengxiong 2025-12-23 11:44:40 +08:00
parent bad3ab281d
commit 1edb9bd8bb
2 changed files with 9 additions and 4 deletions

View File

@ -55,10 +55,10 @@ public class FiletransferServiceImpl implements IFiletransferService {
Uploader uploader = new ChunkUploaderFactory().getUploader(uploadFile);
checkParams(uploadFileDTO, uploadFile);
List<UploadFile> 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());

View File

@ -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));
}
}