Browse Source

fix bug:下载文件关闭流处理有问题

lijie 3 years ago
parent
commit
8addaaa66c

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

@@ -288,8 +288,11 @@ public class CompatibleOldFileServiceImpl implements CompatibleOldFileService {
         }
         // 3.通过文件流的方式下载文件
         InputStream inputStream = service.download(fileInfo.getFileBucket(), fileInfo.getFilePath(), response, fileInfo.getFileName());
-        IoUtil.copy(inputStream,response.getOutputStream());
-        IoUtil.close(inputStream);
+        try {
+            IoUtil.copy(inputStream,response.getOutputStream());
+        }finally {
+            IoUtil.close(inputStream);
+        }
         // 4.2021年12月22日12:00:21,先申请下载地址,然后通过重定向的方式直接请求文件服务器进行下载
 //        String fetchUrl = service.fetchUrl(fileInfo.getFileBucket(), fileInfo.getFilePath());
 //        if (StrUtil.isBlank(fetchUrl)){

+ 1 - 1
dmp-comp/dmp-auth-starter/src/main/java/com/persagy/dmp/auth/config/CommonWebConfigurer.java

@@ -32,7 +32,7 @@ public class CommonWebConfigurer implements WebMvcConfigurer {
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
         String[] includePaths = {"/**"};
-        String[] excludePaths = {"/**/*.html", "/**/*.js", "/**/*.css", "/swagger-resources"};
+        String[] excludePaths = {"/**/*.html", "/**/*.js", "/**/*.css", "/swagger-resources","/**/login"};
         // 设置拦截的路径、不拦截的路径、优先级等等
         registry.addInterceptor(appContextHandler()).order(10).addPathPatterns(includePaths).excludePathPatterns(excludePaths);
     }