[PR #20005] fix: send filename when viewing the original file #16396

Closed
opened 2026-02-05 16:04:46 +03:00 by OVERLORD · 0 comments
Owner

Original Pull Request: https://github.com/immich-app/immich/pull/20005

State: closed
Merged: Yes


Description

This PR makes immich serve the Content-Disposition header on the /api/assets/:id/original endpoint. Currently, the header is served by /thumbnail, but not /original, which this PR fixes.

The PR works by simply adding the fileName field to the ImmichFileResponse returned from downloadOriginal. The exact affected areas are outlined below.

My main reason for adding this, is because I often copy images from immich, rather than downloading them. I noticed that if I right-click the image in the preview and copy it, it'd download an imagename_preview.jpeg, but whenever I zoom in a bit (to load the original) and then copy that image, it'd always be called original.jpeg instead.

This one-liner PR fixes the issue outlined above. I don't see this having any adverse effects on other parts of immich.

This is surfaced to the API here, where sendFile is called: 546f841b2c/server/src/controllers/asset-media.controller.ts (L90)

And within sendFile, the Content-Disposition header is added here: 546f841b2c/server/src/utils/file.ts (L61-L63)

How Has This Been Tested?

Reproducing the issue

  1. Open an unmodified version of immich and click an image, opening the image viewer.
  2. Notice that the image is served from /api/assets/:id/thumbnail, and contains a Content-Disposition header, providing the filename, suffixed with _preview.
  3. Zoom into the image in the preview, and notice the new image is loaded from /api/assets/:id/original, but does not contain a Content-Disposition header, therefore the browser defaults to original.<ext>

After this PR is applied

  1. Open immich with this PR and click an image, opening the image viewer.
  2. As before, the thumbnail has a Content-Disposition header with the filename suffixed with _preview.
  3. Zoom into the image in the preview, and notice the url /api/assets/:id/original now contains a Content-Disposition header with the correct, original filename.

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)
**Original Pull Request:** https://github.com/immich-app/immich/pull/20005 **State:** closed **Merged:** Yes --- ## Description <!--- Describe your changes in detail --> This PR makes immich serve the `Content-Disposition` header on the `/api/assets/:id/original` endpoint. Currently, the header is served by `/thumbnail`, but not `/original`, which this PR fixes. The PR works by simply adding the `fileName` field to the `ImmichFileResponse` returned from `downloadOriginal`. The exact affected areas are outlined below. My main reason for adding this, is because I often copy images from immich, rather than downloading them. I noticed that if I right-click the image in the preview and copy it, it'd download an `imagename_preview.jpeg`, but whenever I zoom in a bit (to load the original) and then copy that image, it'd always be called `original.jpeg` instead. This one-liner PR fixes the issue outlined above. I don't see this having any adverse effects on other parts of immich. This is surfaced to the API here, where `sendFile` is called: https://github.com/immich-app/immich/blob/546f841b2cc1b91226975a9bbe67d8c43dfffb79/server/src/controllers/asset-media.controller.ts#L90 And within `sendFile`, the `Content-Disposition` header is added here: https://github.com/immich-app/immich/blob/546f841b2cc1b91226975a9bbe67d8c43dfffb79/server/src/utils/file.ts#L61-L63 ## How Has This Been Tested? **Reproducing the issue** 1. Open an unmodified version of immich and click an image, opening the image viewer. 2. Notice that the image is served from `/api/assets/:id/thumbnail`, and contains a `Content-Disposition` header, providing the filename, suffixed with `_preview`. 3. Zoom into the image in the preview, and notice the new image is loaded from `/api/assets/:id/original`, but does not contain a `Content-Disposition` header, therefore the browser defaults to `original.<ext>` **After this PR is applied** 1. Open immich with this PR and click an image, opening the image viewer. 2. As before, the thumbnail has a `Content-Disposition` header with the filename suffixed with `_preview`. 3. Zoom into the image in the preview, and notice the url `/api/assets/:id/original` now contains a `Content-Disposition` header with the correct, original filename. ## Checklist: - [x] I have performed a self-review of my own code - [x] I have made corresponding changes to the documentation if applicable - [x] I have no unrelated changes in the PR. - [x] I have confirmed that any new dependencies are strictly necessary. - [x] I have written tests for new code (if applicable) - [x] I have followed naming conventions/patterns in the surrounding code - [x] All code in `src/services/` uses repositories implementations for database calls, filesystem operations, etc. - [x] All code in `src/repositories/` is pretty basic/simple and does not have any immich specific logic (that belongs in `src/services/`)
OVERLORD added the pull-request label 2026-02-05 16:04:46 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#16396