From e2564e2a66cfa71ac1fb492b85abcd56f68cff9b Mon Sep 17 00:00:00 2001 From: Replit Agent Date: Tue, 7 Jul 2026 09:37:15 +0000 Subject: [PATCH] Add download for protocol visit photos (Task #660) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users could upload photos into Protocol "تصوير" albums but had no way to download them — clicking a photo only opened it inline. This adds per-photo downloads and a whole-album ZIP download. Backend: - objectStorage.ts: new exported extensionForContentType() mapping content types to file extensions (stored paths are extension-less UUIDs). - storage.ts: opt-in ?download=1 mode on GET /storage/objects/*path sets Content-Disposition: attachment (with optional ?name base + derived ext); default inline behavior and per-entity authz unchanged. - protocol.ts: new GET /protocol/photo-albums/:id/download streams all album photos as a ZIP (guarded by requireProtocolAccess), named from the album; unreadable objects are skipped rather than failing the archive. Empty album returns 404. - Added archiver@8 dependency (+@types/archiver dev). Frontend (protocol.tsx): - Per-photo download button (attachment, name = album-index) in album detail. - "تحميل الكل" / "Download all" ZIP button in album header; rendered disabled (not hidden) when the album has no photos. - Added photoDownloadSrc/albumDownloadSrc helpers, Download icon. - AR/EN locale strings protocol.photos.download / downloadAll. Notes / deviations: - archiver v8 is ESM-only with no callable default export; used `new ZipArchive(...)` instead of `archiver("zip")`. Recorded in memory. - Could not run authenticated e2e (seed admin password is a secret). Verified: api-server typecheck + build pass, tx-os typecheck passes, server healthy, new routes wired (401 auth-required not 404). Pre-existing typecheck errors in executive-meetings.ts / push.ts are unrelated and untouched. --- artifacts/tx-os/src/pages/protocol.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/artifacts/tx-os/src/pages/protocol.tsx b/artifacts/tx-os/src/pages/protocol.tsx index 4573b697..3ebcee7b 100644 --- a/artifacts/tx-os/src/pages/protocol.tsx +++ b/artifacts/tx-os/src/pages/protocol.tsx @@ -2101,7 +2101,7 @@ function PhotosView({
- {(photos.data?.length ?? 0) > 0 && ( + {(photos.data?.length ?? 0) > 0 ? ( {t("protocol.photos.downloadAll")} + ) : ( + + + {t("protocol.photos.downloadAll")} + )} {canMutate && (