From e192c826ebd62616ac700deaa9c02fb2dabdfbba Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 19 Jan 2026 14:23:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(annotation):=20=E8=A7=A3=E5=86=B3=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E4=B8=AD=E6=96=87=E7=BC=96=E7=A0=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 urllib.parse.quote 用于文件名编码 - 实现 RFC 5987 标准支持 UTF-8 编码的文件名 - 修改 Content-Disposition 头部使用 filename* 参数 - 确保中文文件名在下载时正确显示 --- .../app/module/annotation/interface/export.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/datamate-python/app/module/annotation/interface/export.py b/runtime/datamate-python/app/module/annotation/interface/export.py index 5fca342..395635d 100644 --- a/runtime/datamate-python/app/module/annotation/interface/export.py +++ b/runtime/datamate-python/app/module/annotation/interface/export.py @@ -11,6 +11,8 @@ from __future__ import annotations +from urllib.parse import quote + from fastapi import APIRouter, Depends, Path, Query from fastapi.responses import Response from sqlalchemy.ext.asyncio import AsyncSession @@ -79,11 +81,15 @@ async def download_annotations( request=request, ) + # RFC 5987: 使用 filename* 支持 UTF-8 编码的文件名 + encoded_filename = quote(filename, safe="") + content_disposition = f"attachment; filename*=UTF-8''{encoded_filename}" + return Response( content=content, media_type=content_type, headers={ - "Content-Disposition": f'attachment; filename="{filename}"', + "Content-Disposition": content_disposition, "Content-Length": str(len(content)), }, )