feat: Complete assets proxy implementation with documentation

- Add comprehensive documentation in docs/ASSETS_PROXY.md
- Add contract comments in normalizeAssetUrl and proxy_asset
- Verify all components use normalizeAssetUrl
- Verify ENV variables are correctly set
- Add troubleshooting guide
This commit is contained in:
Apple
2025-12-02 08:36:55 -08:00
parent b49d7489ea
commit 1ca6a4f55a
4 changed files with 363 additions and 1 deletions

View File

@@ -328,7 +328,22 @@ async def update_agent_visibility_endpoint(
async def proxy_asset(path: str):
"""
Proxy endpoint for serving MinIO assets.
Allows serving assets through /api/assets/... instead of requiring assets.daarion.space DNS.
Allows serving assets through /api/city/assets/proxy/... instead of requiring
assets.daarion.space DNS setup.
CONTRACT with normalizeAssetUrl:
- Input from normalizeAssetUrl: /api/city/assets/proxy/microdao/logo/2025/12/02/abc123.png
- Path parameter (after /city/assets/proxy/): microdao/logo/2025/12/02/abc123.png
- MinIO object key: daarion-assets/microdao/logo/2025/12/02/abc123.png
(ASSETS_BUCKET is prepended automatically)
Args:
path: Object path in MinIO (without bucket prefix)
Example: "microdao/logo/2025/12/02/abc123.png"
Returns:
StreamingResponse with image data and appropriate Content-Type
"""
from lib.assets_client import get_minio_client, ASSETS_BUCKET
from fastapi.responses import StreamingResponse
@@ -338,6 +353,8 @@ async def proxy_asset(path: str):
client = get_minio_client()
# Get object from MinIO
# path already contains the full object key (e.g., "microdao/logo/2025/12/02/abc123.png")
# ASSETS_BUCKET is prepended by get_object()
response = client.get_object(ASSETS_BUCKET, path)
# Read data