Add bounded private image upload with safe S3 persistence
This commit is contained in:
+9
-1
@@ -6,6 +6,7 @@ from uuid import UUID
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Request, Response
|
||||
|
||||
from .auth import basic_credentials, bearer_token
|
||||
from .attachments import storage_ready, upload
|
||||
from .models import CreateChat, CreateMessage, CreateUser
|
||||
from .store import store
|
||||
|
||||
@@ -19,7 +20,9 @@ def live():
|
||||
|
||||
@router.get("/health/ready")
|
||||
def ready():
|
||||
return store.ready()
|
||||
result = store.ready()
|
||||
storage_ready()
|
||||
return result
|
||||
|
||||
|
||||
@router.post("/api/v1/users", status_code=201)
|
||||
@@ -78,6 +81,11 @@ def get_chat(chat_id: UUID, actor: dict = Depends(current_user)):
|
||||
return store.chat(actor["id"], str(chat_id))
|
||||
|
||||
|
||||
@router.post("/api/v1/chats/{chat_id}/attachments", status_code=201)
|
||||
async def upload_attachment(chat_id: UUID, request: Request, filename: str = Query(...), actor: dict = Depends(current_user)):
|
||||
return await upload(request, str(chat_id), actor["id"], filename)
|
||||
|
||||
|
||||
@router.post("/api/v1/chats/{chat_id}/messages", status_code=201)
|
||||
def create_message(chat_id: UUID, body: CreateMessage, request: Request, actor: dict = Depends(current_user)):
|
||||
key = request.headers.get("Idempotency-Key")
|
||||
|
||||
Reference in New Issue
Block a user