Commit a5ad8bb708d708ef5e9d2a2e7bc12deb99ee924e
1 parent
af2a0c22
fix: 修复上传MP4文件之后通过下载连接下载MP4文件源文件能通过windows自带播放器播放下载下来的播放不了
Showing
1 changed file
with
2 additions
and
3 deletions
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/framework/file/core/utils/FileTypeUtils.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.framework.file.core.utils; |
| 3 | 3 | import cn.hutool.core.io.IoUtil; |
| 4 | 4 | import cn.hutool.core.util.StrUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.util.http.HttpUtils; |
| 6 | -import com.alibaba.ttl.TransmittableThreadLocal; | |
| 7 | 6 | import jakarta.servlet.http.HttpServletResponse; |
| 8 | 7 | import lombok.SneakyThrows; |
| 9 | 8 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -86,8 +85,8 @@ public class FileTypeUtils { |
| 86 | 85 | response.setContentType(contentType); |
| 87 | 86 | // 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题 |
| 88 | 87 | if (StrUtil.containsIgnoreCase(contentType, "video")) { |
| 89 | - response.setHeader("Content-Length", String.valueOf(content.length - 1)); | |
| 90 | - response.setHeader("Content-Range", String.valueOf(content.length - 1)); | |
| 88 | + response.setHeader("Content-Length", String.valueOf(content.length)); | |
| 89 | + response.setHeader("Content-Range", "bytes 0-" + (content.length - 1) + "/" + content.length); | |
| 91 | 90 | response.setHeader("Accept-Ranges", "bytes"); |
| 92 | 91 | } |
| 93 | 92 | // 输出附件 | ... | ... |