Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/develop' into develop

linhuili 2 anni fa
parent
commit
b35cdedb88

+ 5 - 1
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/service/impl/FileServiceImpl.java

@@ -272,6 +272,7 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileInfo> implement
      * @author : lijie
      * Update By lijie 2021/10/23 13:18
      */
+    @SneakyThrows
     @Override
     public FileInfo initFileDownload(FileRequestData requestData) {
         FileInfo fileInfo = fileMapper.getFileInfoById(requestData.getFileId());
@@ -279,7 +280,10 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileInfo> implement
         if (null==fileInfo || !service.exists(fileInfo.getFileBucket(),fileInfo.getFilePath())){
             throw new BusinessException("文件不存在");
         }
-        String fetchUrl = FileStorageFactory.getService().fetchUrl(fileInfo.getFileBucket(), fileInfo.getFilePath());
+        String fetchUrl = FileStorageFactory.getService().fetchUrl(fileInfo.getFileBucket(), fileInfo.getFilePath(),MapUtil
+                .of(FileCommonConst.RESPONSE_CONTENT_DISPOSITION,StrUtil
+                        .format(FileCommonConst.REPONSE_HEAD_CONTENT_DISPOSITION_ATTACHMENT,
+                                URLEncoder.encode(fileInfo.getFileName(), "UTF-8"))));
         fileInfo.setFileDownloadUrl(fetchUrl);
         return fileInfo;
     }