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)), }, )