获取上传状态
(upload_id: str)
| 530 | "/upload/status/{upload_id}", dependencies=[Depends(share_required_login)] |
| 531 | ) |
| 532 | async def get_upload_status(upload_id: str): |
| 533 | """获取上传状态""" |
| 534 | chunk_info = await UploadChunk.filter(upload_id=upload_id, chunk_index=-1).first() |
| 535 | if not chunk_info: |
| 536 | raise HTTPException(status.HTTP_404_NOT_FOUND, detail="上传会话不存在") |
| 537 | |
| 538 | # 获取已上传的分片列表 |
| 539 | uploaded_chunks = await UploadChunk.filter( |
| 540 | upload_id=upload_id, completed=True |
| 541 | ).values_list("chunk_index", flat=True) |
| 542 | |
| 543 | return APIResponse( |
| 544 | detail={ |
| 545 | "upload_id": upload_id, |
| 546 | "file_name": chunk_info.file_name, |
| 547 | "file_size": chunk_info.file_size, |
| 548 | "chunk_size": chunk_info.chunk_size, |
| 549 | "total_chunks": chunk_info.total_chunks, |
| 550 | "uploaded_chunks": list(uploaded_chunks), |
| 551 | "progress": len(uploaded_chunks) / chunk_info.total_chunks * 100, |
| 552 | } |
| 553 | ) |
| 554 | |
| 555 | |
| 556 | @chunk_api.post( |
nothing calls this directly
no test coverage detected