调整断点续传

This commit is contained in:
wenc000 2020-08-26 18:01:02 +08:00
parent 7db0f91c87
commit d31e3d93dc

View File

@ -252,7 +252,7 @@ public class FileServiceImpl extends AbstractService implements IFileService {
*/
private void setRangeHeader(long startRange, long endRange, HttpServletResponse response, String fileId, long contentLength) {
// 这里不设置会出现第一次加载很慢的情况
response.setHeader("Content-Length", String.valueOf(contentLength - startRange));
response.setHeader("Content-Length", String.valueOf(endRange - startRange + 1));
response.setHeader("Content-Range", String.format("bytes %d-%d/%d", startRange, endRange, contentLength));
response.setHeader("Accept-Ranges", "bytes");
response.setHeader("Etag", fileId);