소스 검색

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

linhuili 2 년 전
부모
커밋
b35cdedb88
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/service/impl/FileServiceImpl.java

+ 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;
     }