【功能新增】IoT:实现 IotRuleSceneDataBridgeAction 的 http 部分的逻辑

This commit is contained in:
YunaiV
2025-02-03 18:33:43 +08:00
parent 5e71d1fc85
commit 7168e60fdd
12 changed files with 229 additions and 21 deletions

View File

@@ -2,13 +2,13 @@ package cn.iocoder.yudao.module.infra.framework.file.core.utils;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.util.http.HttpUtils;
import com.alibaba.ttl.TransmittableThreadLocal;
import jakarta.servlet.http.HttpServletResponse;
import lombok.SneakyThrows;
import org.apache.tika.Tika;
import java.io.IOException;
import java.net.URLEncoder;
/**
* 文件类型 Utils
@@ -60,7 +60,7 @@ public class FileTypeUtils {
*/
public static void writeAttachment(HttpServletResponse response, String filename, byte[] content) throws IOException {
// 设置 header 和 contentType
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
response.setHeader("Content-Disposition", "attachment;filename=" + HttpUtils.encodeUtf8(filename));
String contentType = getMineType(content, filename);
response.setContentType(contentType);
// 针对 video 的特殊处理,解决视频地址在移动端播放的兼容性问题