Added RPG
This commit is contained in:
@@ -56,6 +56,23 @@ async def patch_card(card_id: str, body: CardPatch):
|
||||
return await get_character(card_id)
|
||||
|
||||
|
||||
@router.post("/{card_id}/avatar")
|
||||
async def upload_avatar(card_id: str, file: UploadFile = File(...)):
|
||||
card = await get_character(card_id)
|
||||
if not card:
|
||||
raise HTTPException(status_code=404, detail="Карточка не найдена")
|
||||
content = await file.read()
|
||||
if not content.startswith(b"\x89PNG"):
|
||||
raise HTTPException(status_code=400, detail="Нужен PNG")
|
||||
from services.character_card import _save_avatar_bytes
|
||||
rel = _save_avatar_bytes(content, f"card_{card_id}")
|
||||
await update_character(card_id, {"avatar_path": rel})
|
||||
# sync persona
|
||||
from services.personas import patch_persona
|
||||
await patch_persona(f"card_{card_id}", {"avatar_path": rel})
|
||||
return {"avatar_path": f"/static/{rel}"}
|
||||
|
||||
|
||||
@router.post("/import")
|
||||
async def import_card(
|
||||
file: UploadFile = File(...),
|
||||
|
||||
Reference in New Issue
Block a user