Add bounded private image upload with safe S3 persistence
This commit is contained in:
+2
-1
@@ -37,7 +37,8 @@ def error_response(request: Request, status: int, extra_headers: dict | None = N
|
||||
@app.middleware("http")
|
||||
async def request_contract(request: Request, call_next):
|
||||
request.state.request_id = str(uuid4())
|
||||
if request.method == "POST" and request.url.path.startswith("/api/v1/") and request.url.path != "/api/v1/auth/sessions":
|
||||
is_upload = request.url.path.startswith("/api/v1/chats/") and request.url.path.endswith("/attachments")
|
||||
if request.method == "POST" and request.url.path.startswith("/api/v1/") and request.url.path != "/api/v1/auth/sessions" and not is_upload:
|
||||
media_type, _, charset = request.headers.get("content-type", "").lower().partition(";")
|
||||
if media_type.strip() != "application/json" or (charset and charset.strip() != "charset=utf-8"):
|
||||
return error_response(request, 415)
|
||||
|
||||
Reference in New Issue
Block a user