feat(rabbits): photo attachments via local volume (#23) #32
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/rabbit-photos"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #23.
Keeping it simple to start, per the issue discussion: local disk storage rather than object storage.
Rabbit.photo_filenamecolumn + migrationapp/storage.py: saves uploads underRABBITDB_PHOTOS_DIR(default/data/photos), validates content-type (jpeg/png/webp) and size (<=8MB)/photosstatic mount serves the photos directoryPOST/DELETE /rabbits/{id}/photophoto_urladded to/api/v1/rabbitsresponsesCompanion homelab PR mounts a volume at
/opt/podman/rabbitdb:/data/photosand switches the container to run as 1000:1000 (it was running as root before): see cpressland/homelab.Open questions from the issue (single photo vs gallery, size/format constraints) — went with single photo + jpeg/png/webp up to 8MB as the simple starting point; easy to extend later.
- Add Rabbit.photo_filename column (nullable, migration in main.py) - New app/storage.py: local-disk photo storage under RABBITDB_PHOTOS_DIR (defaults to /data/photos), validates content-type (jpeg/png/webp) and size (<=8MB), random filename per upload - Mount /photos as a static route serving RABBITDB_PHOTOS_DIR - Staff-authenticated upload/replace/remove endpoints: POST/DELETE /rabbits/{id}/photo, returning the rabbits/_photo.html partial - Show photo (or placeholder) on rabbit detail page, list rows (thumbnail), family tree nodes, and the public adoption form - Old file is deleted from disk when a photo is replaced or removed - Expose photo_url on the read-only /api/v1/rabbits endpoints Local volume storage only for now, per issue discussion; object storage can be swapped in later behind the same storage.py functions.