diff --git a/pom.xml b/pom.xml index 8ae00d3..5c72108 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ com.imyeyu.timiserverapi TimiServerAPI - 1.0.72 + 1.0.73 jar TimiServerAPI imyeyu.com API diff --git a/src/main/java/com/imyeyu/api/modules/common/controller/AttachmentController.java b/src/main/java/com/imyeyu/api/modules/common/controller/AttachmentController.java index a98e1b7..f398da6 100644 --- a/src/main/java/com/imyeyu/api/modules/common/controller/AttachmentController.java +++ b/src/main/java/com/imyeyu/api/modules/common/controller/AttachmentController.java @@ -260,7 +260,9 @@ public class AttachmentController { } private void setDownloadHeader(Attachment attachment) throws UnsupportedEncodingException { - if (attachment != null && TimiSpring.getRequest().getRequestURI().endsWith("/download") && attachment.getName() != null) { + // 路径带 /download 就强制下载:/download/{id} 的结尾是 id,用 endsWith 匹配不到 + boolean download = TimiSpring.getRequest().getRequestURI().contains("/download"); + if (attachment != null && download && attachment.getName() != null) { TimiSpring.getResponse().setHeader("Content-Disposition", Network.getFileDownloadHeader(attachment.getName())); } }