|
|
@@ -146,14 +146,18 @@ async def ws_excel(websocket: WebSocket,
|
|
|
|
|
|
|
|
|
@router.get("/download/{file_full_name}")
|
|
|
-async def download_file(background_tasks: BackgroundTasks, file_full_name: str):
|
|
|
+async def download_file(file_full_name: str):
|
|
|
file_name = os.path.basename(file_full_name)
|
|
|
user_excel = EXCEL_FILES_PATH
|
|
|
file_path = os.path.join(user_excel, file_full_name)
|
|
|
|
|
|
if not os.path.exists(file_path):
|
|
|
return JSONResponse(content={"error": "文件不存在"}, status_code=404)
|
|
|
-
|
|
|
+ return FileResponse(
|
|
|
+ path=file_path,
|
|
|
+ filename=file_name,
|
|
|
+ media_type='application/octet-stream',
|
|
|
+ )
|
|
|
# def delete_file():
|
|
|
# try:
|
|
|
# os.unlink(file_path)
|