uploader-bot/app/api/routes/upload_status.py

18 lines
508 B
Python

from sanic import response
from app.core.models.content_v3 import UploadSession
async def s_api_v1_upload_status(request, upload_id: str):
session = request.ctx.db_session
row = await session.get(UploadSession, upload_id)
if not row:
return response.json({"error": "NOT_FOUND"}, status=404)
return response.json({
"id": row.id,
"state": row.state,
"encrypted_cid": row.encrypted_cid,
"size_bytes": row.size_bytes,
"error": row.error,
})