取消上传会话
(upload_id: str)
| 796 | |
| 797 | @presign_api.delete("/upload/{upload_id}", dependencies=[Depends(share_required_login)]) |
| 798 | async def presign_upload_cancel(upload_id: str): |
| 799 | """取消上传会话""" |
| 800 | session = await PresignUploadSession.filter(upload_id=upload_id).first() |
| 801 | if not session: |
| 802 | raise HTTPException(404, "上传会话不存在") |
| 803 | |
| 804 | if session.mode == "direct": |
| 805 | storage: FileStorageInterface = storages[settings.file_storage]() |
| 806 | try: |
| 807 | if await storage.file_exists(session.save_path): |
| 808 | temp_file_code = FileCodes( |
| 809 | file_path=os.path.dirname(session.save_path), |
| 810 | uuid_file_name=os.path.basename(session.save_path), |
| 811 | ) |
| 812 | await storage.delete_file(temp_file_code) |
| 813 | except Exception: |
| 814 | pass |
| 815 | |
| 816 | await session.delete() |
| 817 | return APIResponse(detail={"message": "上传会话已取消"}) |
nothing calls this directly
no test coverage detected