diff --git a/video-gen-api/app/api/v1/team.py b/video-gen-api/app/api/v1/team.py index 12e1f8fb..e37fc4a1 100644 --- a/video-gen-api/app/api/v1/team.py +++ b/video-gen-api/app/api/v1/team.py @@ -370,10 +370,13 @@ async def export_team_credit_records( ]) from starlette.responses import StreamingResponse + from urllib.parse import quote output.seek(0) - filename = f"团队积分_{team.name}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" + safe_team_name = team.name or "team" + filename = f"团队积分_{safe_team_name}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv" + encoded_filename = quote(filename) return StreamingResponse( iter([output.getvalue()]), media_type="text/csv; charset=utf-8-sig", - headers={"Content-Disposition": f"attachment; filename*=UTF-8''{filename}"}, + headers={"Content-Disposition": f"attachment; filename*=UTF-8''{encoded_filename}"}, )