Replace the presigned-URL redirect (302) in GET /api/v1/images/{id}/file
with a direct proxy that fetches bytes from S3 server-side and returns them
to the client. The browser never contacts the storage backend, eliminating
the /etc/hosts workaround needed in local development.
- StorageBackend: swap get_presigned_url for get(key) -> bytes
- S3StorageBackend: implement get() via aiobotocore get_object
- serve_image_file: return Response with ETag + Cache-Control: immutable
- test_serving: assert 200 + content-type + ETag; add no-storage-details test
- Spec Kit artifacts for feature 002-api-image-proxy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 lines
433 B
Python
16 lines
433 B
Python
from abc import ABC, abstractmethod
|
|
|
|
|
|
class StorageBackend(ABC):
|
|
@abstractmethod
|
|
async def put(self, key: str, data: bytes, content_type: str) -> None:
|
|
"""Store object at key with given content type."""
|
|
|
|
@abstractmethod
|
|
async def get(self, key: str) -> bytes:
|
|
"""Return object content as bytes."""
|
|
|
|
@abstractmethod
|
|
async def delete(self, key: str) -> None:
|
|
"""Delete object at key."""
|