Parcourir la source

Merge branch 'develop' of http://39.106.8.246:3003/BDTP/digital-twin into develop

lvxianyun il y a 3 ans
Parent
commit
581d6668bc

+ 4 - 0
dmp-cloud/dmp-file/src/main/java/com/persagy/dmp/file/service/impl/CompatibleOldFileServiceImpl.java

@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.servlet.http.HttpServletResponse;
 import java.io.InputStream;
 import java.net.URLEncoder;
+import java.text.MessageFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -289,6 +290,9 @@ public class CompatibleOldFileServiceImpl implements CompatibleOldFileService {
         IoUtil.copy(service.download(fileInfo.getFileBucket(),fileInfo.getFilePath()),response.getOutputStream());
         response.setHeader(CommonConstant.REPONSE_HEAD_CONTENT_DISPOSITION,
                 CommonConstant.REPONSE_HEAD_CONTENT_DISPOSITION_ATTACHMENT + URLEncoder.encode(fileInfo.getFileName(), "UTF-8"));
+        response.setHeader(CommonConstant.REPONSE_HEAD_CONTENT_LENGTH, null==fileInfo.getFileSize()?"0":fileInfo.getFileSize().toString());
+        response.setHeader("Accept-Ranges", "bytes");
+        response.setHeader("Content-Range", StrUtil.format("bytes {}-{}/{}", 0, fileInfo.getFileSize().toString(), fileInfo.getFileSize().toString()));
         // 4.2021年12月22日12:00:21,先申请下载地址,然后通过重定向的方式直接请求文件服务器进行下载
 //        String fetchUrl = service.fetchUrl(fileInfo.getFileBucket(), fileInfo.getFilePath());
 //        if (StrUtil.isBlank(fetchUrl)){

+ 3 - 0
dmp-cloud/dmp-file/src/main/resources/bootstrap.yml

@@ -6,6 +6,9 @@ spring:
       force: true
       charset: utf-8
       enabled: true
+  servlet:
+    multipart:
+      enabled: true
 
 persagy:
   common:

+ 4 - 6
dmp-common/src/main/java/com/persagy/dmp/common/constant/CommonConstant.java

@@ -55,11 +55,9 @@ public interface CommonConstant {
     /** result字段 */
     String RESULT ="result";
     /**响应头:Content-disposition*/
-    public static final String REPONSE_HEAD_CONTENT_DISPOSITION = "Content-disposition";
-    /**响应头:Content-Type*/
-    public static final String REPONSE_HEAD_CONTENT_TYPE = "Content-Type";
-    /**响应头:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet*/
-    public static final String REPONSE_HEAD_CONTENT_TYPE_SHEET = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
+    String REPONSE_HEAD_CONTENT_DISPOSITION = "Content-disposition";
+    /**响应头:Content-disposition*/
+    String REPONSE_HEAD_CONTENT_LENGTH = "Content-Length";
     /**响应头:attachment;filename=*/
-    public static final String REPONSE_HEAD_CONTENT_DISPOSITION_ATTACHMENT = "attachment;filename=";
+    String REPONSE_HEAD_CONTENT_DISPOSITION_ATTACHMENT = "attachment;filename=";
 }