Commit 98308558647c9aa8f119fea7ee459e78c8b3e525

Authored by 芯火源
1 parent 06aa0b80

fix: 修复文件下载404问题

... ... @@ -142,7 +142,7 @@ public class LocalFileStorageService implements FileStorageService {
142 142 fileName = RandomStringUtils.randomAlphabetic(15);
143 143 }
144 144 String date = LocalDateTime.now().format(DateTimeFormatter.ISO_DATE);
145   - fileName = date + "-" + fileName;
  145 + fileName = date + "_" + fileName;
146 146 }
147 147 // Check if the file's name contains invalid characters
148 148 if (fileName.contains("..")) {
... ...
... ... @@ -126,9 +126,9 @@ public class MinioFileStorageService implements FileStorageService {
126 126 .getRequest();
127 127 // 生成下载接口的地址
128 128 String realDownloadPath =
129   - request.getRequestURL().toString().replace("upload", "downloadFile/" + fileName);
  129 + request.getRequestURL().toString().replace("upload", "download_file/" + fileName);
130 130 return new FileUploadResponse(
131   - fileName, realDownloadPath, file.getContentType(), file.getSize(), staticPath);
  131 + fileName.replace("/","_"), realDownloadPath, file.getContentType(), file.getSize(), staticPath);
132 132 }
133 133
134 134 @Override
... ... @@ -141,7 +141,7 @@ public class MinioFileStorageService implements FileStorageService {
141 141 minioClient.getObject(
142 142 GetObjectArgs.builder()
143 143 .bucket(fileStorageProperties.getBucketName())
144   - .object(fileName)
  144 + .object(fileName.replace("_","/"))
145 145 .build());
146 146 // 获取输出流
147 147 OutputStream outputStream = response.getOutputStream()) {
... ...