fix: 解决下载文件扩展名的问题

This commit is contained in:
oliviamn 2025-07-17 00:20:11 +08:00
parent 19d8e4a0b1
commit 68765ab45f
1 changed files with 7 additions and 2 deletions

View File

@ -89,10 +89,15 @@ async def download_file(
if not os.path.exists(file.processed_path):
raise HTTPException(status_code=404, detail="Processed file not found")
# Get the original filename without extension and add .md extension
original_filename = file.filename
filename_without_ext = os.path.splitext(original_filename)[0]
download_filename = f"{filename_without_ext}.md"
return FileResponse(
path=file.processed_path,
filename=file.filename,
media_type="application/octet-stream"
filename=download_filename,
media_type="text/markdown"
)
@router.websocket("/ws/status/{file_id}")