Przeglądaj źródła

调整旧文件服务的下载方式,改为重定向下载地址方式

lijie 3 lat temu
rodzic
commit
f733284bae

+ 9 - 2
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/service/impl/CompatibleOldFileServiceImpl.java

@@ -284,8 +284,15 @@ public class CompatibleOldFileServiceImpl implements CompatibleOldFileService {
             IoUtil.writeUtf8(response.getOutputStream(),Boolean.FALSE,"File not existed");
             return;
         }
-        // 3.下载文件
-        IoUtil.copy(service.download(fileInfo.getFileBucket(),fileInfo.getFilePath()),response.getOutputStream());
+        // 3.通过文件流的方式下载文件
+        // IoUtil.copy(service.download(fileInfo.getFileBucket(),fileInfo.getFilePath()),response.getOutputStream());
+        // 4.2021年12月22日12:00:21,先申请下载地址,然后通过重定向的方式直接请求文件服务器进行下载
+        String fetchUrl = service.fetchUrl(fileInfo.getFileBucket(), fileInfo.getFilePath());
+        if (StrUtil.isBlank(fetchUrl)){
+            IoUtil.writeUtf8(response.getOutputStream(),Boolean.FALSE,"File not existed");
+            return;
+        }
+        response.sendRedirect(fetchUrl);
     }
 
     /***