fix: 解决下载文件扩展名的问题
This commit is contained in:
parent
19d8e4a0b1
commit
68765ab45f
|
|
@ -89,10 +89,15 @@ async def download_file(
|
||||||
if not os.path.exists(file.processed_path):
|
if not os.path.exists(file.processed_path):
|
||||||
raise HTTPException(status_code=404, detail="Processed file not found")
|
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(
|
return FileResponse(
|
||||||
path=file.processed_path,
|
path=file.processed_path,
|
||||||
filename=file.filename,
|
filename=download_filename,
|
||||||
media_type="application/octet-stream"
|
media_type="text/markdown"
|
||||||
)
|
)
|
||||||
|
|
||||||
@router.websocket("/ws/status/{file_id}")
|
@router.websocket("/ws/status/{file_id}")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue