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

Function cancel_upload

apps/base/views.py:507–526  ·  view source on GitHub ↗

取消上传并清理临时文件

(upload_id: str)

Source from the content-addressed store, hash-verified

505
506@chunk_api.delete("/upload/{upload_id}", dependencies=[Depends(share_required_login)])
507async def cancel_upload(upload_id: str):
508 """取消上传并清理临时文件"""
509 chunk_info = await UploadChunk.filter(upload_id=upload_id, chunk_index=-1).first()
510 if not chunk_info:
511 raise HTTPException(status.HTTP_404_NOT_FOUND, detail="上传会话不存在")
512
513 save_path = chunk_info.save_path
514
515 # 清理存储中的临时文件
516 storage = storages[settings.file_storage]()
517 if save_path:
518 try:
519 await storage.clean_chunks(upload_id, save_path)
520 except Exception as e:
521 pass
522
523 # 清理数据库记录
524 await UploadChunk.filter(upload_id=upload_id).delete()
525
526 return APIResponse(detail={"message": "上传已取消"})
527
528
529@chunk_api.get(

Callers

nothing calls this directly

Calls 5

APIResponseClass · 0.90
deleteMethod · 0.80
firstMethod · 0.45
filterMethod · 0.45
clean_chunksMethod · 0.45

Tested by

no test coverage detected