feat(backend): media library: files once by hash, WebP sizes, cached, protected while used (platform-v2 step 5.1)
- Table `media` (Alembic 0026): kind, name, original name, type, sha256
(unique), bytes, width/height, video length, who and when.
- Files under /app/data/media/<sha[:2]>/<sha>/: the original, and for
pictures thumb (200 px) / card (600) / full (1920) WebP, upright from
EXIF, never enlarged, transparency kept. Videos (MP4, WebM) kept as
uploaded; an MP4's length and size come from its header.
- GET/POST /api/media, GET/PATCH/DELETE /api/media/{id} for whoever manages
the menu, customer display, signage or menu tablets. The same file again
returns the existing item. The type comes from the bytes; 20 MB pictures,
200 MB videos, 60 MP; refused uploads leave nothing behind.
- GET /api/media/file/<sha>/<variant>: public (LAN), Cache-Control
public, max-age=1 year, immutable; byte ranges for video; a missing size
is made again from the original.
- register_usage(kind, fn): what uses media (products, displays, signage
from 5.2-5.4) declares it; delete is refused with media.in_use listing
the users.
- tests: test_media.py (12); stack.mjs uploads 3 MB through both nginx hops
and fetches a size with its cache headers (compose stack: all passed).
Backend suite: 490 passed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,14 @@
|
||||
"media_too_big": "Η εικόνα είναι πολύ μεγάλη (έως {{max_mb}} MB).",
|
||||
"qr_url_missing": "Γράψτε τον σύνδεσμο που ανοίγει ο QR κωδικός."
|
||||
},
|
||||
"media": {
|
||||
"not_found": "Το αρχείο {{media_id}} δεν υπάρχει στη βιβλιοθήκη πολυμέσων.",
|
||||
"type": "Ανεβάστε εικόνα (JPG, PNG, WebP ή GIF) ή βίντεο (MP4 ή WebM).",
|
||||
"too_big": "Το αρχείο είναι πολύ μεγάλο (έως {{max_mb}} MB).",
|
||||
"too_many_pixels": "Η εικόνα είναι πολύ μεγάλη (έως {{max_mp}} megapixel).",
|
||||
"unreadable": "Αυτή η εικόνα δεν διαβάζεται. Αποθηκεύστε τη ξανά ως JPG ή PNG και ανεβάστε τη.",
|
||||
"in_use": "Αυτό το αρχείο χρησιμοποιείται από: {{uses}}. Αφαιρέστε το πρώτα από εκεί."
|
||||
},
|
||||
"caller_id": {
|
||||
"key_invalid": "Το κλειδί του τηλεφωνικού κέντρου λείπει ή είναι λάθος."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user