fix(attach): lost file name for download

This commit is contained in:
Timi
2026-11-17 14:26:09 +08:00
parent 5233ac7eef
commit 725503152e
@@ -260,7 +260,9 @@ public class AttachmentController {
} }
private void setDownloadHeader(Attachment attachment) throws UnsupportedEncodingException { 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())); TimiSpring.getResponse().setHeader("Content-Disposition", Network.getFileDownloadHeader(attachment.getName()));
} }
} }