lijie 3 rokov pred
rodič
commit
ce8784be56

+ 3 - 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;
 
@@ -290,6 +291,8 @@ public class CompatibleOldFileServiceImpl implements CompatibleOldFileService {
         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)){