MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / presign_upload_cancel

Function presign_upload_cancel

apps/base/views.py:798–817  ·  view source on GitHub ↗

取消上传会话

(upload_id: str)

Source from the content-addressed store, hash-verified

796
797@presign_api.delete("/upload/{upload_id}", dependencies=[Depends(share_required_login)])
798async 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": "上传会话已取消"})

Callers

nothing calls this directly

Calls 7

FileCodesClass · 0.90
APIResponseClass · 0.90
deleteMethod · 0.80
firstMethod · 0.45
filterMethod · 0.45
file_existsMethod · 0.45
delete_fileMethod · 0.45

Tested by

no test coverage detected