fix(文件管理): 批量下载时文件名增加唯一标识
--bug=1039607 --user=宋天阳 https://www.tapd.cn/55049933/s/1500081
This commit is contained in:
parent
fa0daf63d3
commit
17cde73898
|
@ -353,7 +353,7 @@ public class FileMetadataService {
|
|||
|
||||
public void batchDownloadWithResponse(List<FileMetadata> fileMetadataList, HttpServletResponse response) {
|
||||
Map<String, File> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue