xuyonghao
2025-01-08 df14f81b4d34b7aea88bb5e72cbdaba70f7d728f
app/api/excel.py
@@ -146,14 +146,18 @@
@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)