From ab042b367dc5a4fae85d6a7ef0745de3d88a6bce Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Sat, 27 Jun 2020 18:41:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E8=A7=86=E9=A2=91=E7=AC=AC?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E5=8A=A0=E8=BD=BD=E6=85=A2=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cm/common/plugin/service/file/impl/FileServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java index 9b36eea..24aef54 100644 --- a/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java +++ b/cloud-common-plugin/src/main/java/com/cm/common/plugin/service/file/impl/FileServiceImpl.java @@ -251,6 +251,8 @@ public class FileServiceImpl extends AbstractService implements IFileService { * @param contentLength */ private void setRangeHeader(long startRange, long endRange, HttpServletResponse response, String fileId, long contentLength) { + // 这里不设置,会出现第一次加载很慢的情况 + response.setHeader("Content-Length", String.valueOf(contentLength - startRange)); response.setHeader("Content-Range", String.format("bytes %d-%d/%d", startRange, endRange, contentLength)); response.setHeader("Accept-Ranges", "bytes"); response.setHeader("Etag", fileId);