diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java index d238b7b4..1b99af47 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/NewDatasetServiceImpl.java @@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.InputStreamResource; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -527,10 +528,21 @@ public class NewDatasetServiceImpl implements NewDatasetService { headers.put("Authorization", "Token " + labelDatasetVersionVo.getToken()); InputStream inputStream = HttpUtils.getIntputStream(labelloaclUrl + "/api/projects/" + labelDatasetVersionVo.getProjectId() + "/export?exportType=" + labelDatasetVersionVo.getExportType(), headers); - // 2. 打包成zip包 -// String zipFileName = labelDatasetVersionVo.getName() + "_" + labelDatasetVersionVo.getVersion() + ".zip"; - String zipFileName = labelDatasetVersionVo.getName() + "_" + labelDatasetVersionVo.getVersion(); - MultipartFile[] files = FileUtil.toMultipartFiles(inputStream, zipFileName); + // 2. 直接保存zip文件,不要重新打包 + String zipFileName = labelDatasetVersionVo.getName() + "_" + labelDatasetVersionVo.getVersion() + ".zip"; + + // 将InputStream转换为byte数组 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int length; + while ((length = inputStream.read(buffer)) >= 0) { + baos.write(buffer, 0, length); + } + inputStream.close(); + + // 创建MultipartFile + ByteArrayResource resource = new ByteArrayResource(baos.toByteArray()); + MultipartFile[] files = new MultipartFile[]{new FileUtil.CustomMultipartFile(resource, zipFileName)}; // 3. 上传到minio List> maps = uploadDatasetlocal(files, UUID.randomUUID().toString());