From f974fc753f3105348b9a00336f12fdb2d9edc53f Mon Sep 17 00:00:00 2001 From: Alan Grainger Date: Mon, 18 Nov 2024 14:18:13 +0100 Subject: [PATCH] Fix issue with video downloads and file names --- app/package.json | 2 +- app/src/render.ts | 8 +++++++- app/views/gallery.ejs | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/package.json b/app/package.json index d171ab0..5b7132b 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "immich-public-proxy", - "version": "1.5.0", + "version": "1.5.1", "scripts": { "dev": "ts-node src/index.ts", "build": "npx tsc", diff --git a/app/src/render.ts b/app/src/render.ts index 99ed4be..98691eb 100644 --- a/app/src/render.ts +++ b/app/src/render.ts @@ -53,6 +53,11 @@ class Render { }) const data = await fetch(url, { headers }) + // Add the filename for downloaded assets + if (size === ImageSize.original && asset.originalFileName && getConfigOption('ipp.downloadOriginalPhoto', true)) { + res.setHeader('Content-Disposition', `attachment; filename="${asset.originalFileName}"`) + } + // Return the response to the client if (data.status >= 200 && data.status < 300) { // Populate the whitelisted response headers @@ -97,7 +102,8 @@ class Render { controls: true } }) - } else if (asset.type === AssetType.image && getConfigOption('ipp.downloadOriginalPhoto', true)) { + } + if (getConfigOption('ipp.downloadOriginalPhoto', true)) { // Add a download link for the original-size image, if configured in config.json downloadUrl = immich.photoUrl(share.key, asset.id, ImageSize.original, asset.password) } diff --git a/app/views/gallery.ejs b/app/views/gallery.ejs index de58d33..3f8287c 100644 --- a/app/views/gallery.ejs +++ b/app/views/gallery.ejs @@ -21,7 +21,11 @@
<% items.forEach(item => { if (item.video) { %> - + + data-download-url="<%- item.downloadUrl %>" + <% } %> + >