diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java index eff8589d83..fdff50b10e 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileMetadataService.java @@ -353,7 +353,7 @@ public class FileMetadataService { public void batchDownloadWithResponse(List fileMetadataList, HttpServletResponse response) { Map fileMap = new HashMap<>(); - fileMetadataList.forEach(fileMetadata -> fileMap.put(FileMetadataUtils.getFileName(fileMetadata), this.getTmpFile(fileMetadata))); + fileMetadataList.forEach(fileMetadata -> fileMap.put(FileMetadataUtils.getFileNameWithId(fileMetadata), this.getTmpFile(fileMetadata))); FileDownloadUtils.zipFilesWithResponse(fileMap, response); } diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java b/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java index 9c2cbf33b9..33e3fd9c32 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/utils/FileMetadataUtils.java @@ -34,6 +34,13 @@ public class FileMetadataUtils { return fileMetadata.getName() + "." + fileMetadata.getType(); } + public static String getFileNameWithId(FileMetadata fileMetadata) { + if (StringUtils.isBlank(fileMetadata.getType())) { + return fileMetadata.getName() + "_" + fileMetadata.getId(); + } + return fileMetadata.getName() + "_" + fileMetadata.getId() + "." + fileMetadata.getType(); + } + /** * 将空文件类型转换为unknown *