- Issue created by @thatguy
- Issue was unassigned.
- Status changed to Needs review
10 months ago 12:01pm 31 January 2024 - last update
10 months ago 2 fail The last submitted patch, 2: media-entity-download-filename-in-download-3418334-2.patch, failed testing. View results →
- Status changed to RTBC
10 months ago 11:41am 2 February 2024 - 🇫🇮Finland Alexander Tallqvist
Tested the patch #2 with Drupal 10.1.8 and media_entity_download 2.0.0. Seems to be working as intended on our site. The files now have the correct filenames as their names when downloading them.
- 🇩🇰Denmark nicklasmf
I like the idea but I get the following:
Warning: Undefined array key "Content-Disposition" in Drupal\media_entity_download\Controller\DownloadController->download() (line 154 of modules/contrib/media_entity_download/src/Controller/DownloadController.php). Drupal\media_entity_download\Controller\DownloadController->download(Object)
So maybe it should be turned around:
if (isset($headers['Content-Disposition']) && !empty($content_disposition = $headers['Content-Disposition'])) { // Key exists and is not empty, so we proceed with the logic. if (!str_contains($content_disposition, 'filename')) { $response->setContentDisposition($content_disposition, $filename); } } else { // Key does not exist or is empty, so we set default disposition. if ($request_query->has(ResponseHeaderBag::DISPOSITION_INLINE)) { $disposition = ResponseHeaderBag::DISPOSITION_INLINE; } else { $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT; } $response->setContentDisposition($disposition, $filename); }
- 🇩🇰Denmark nicklasmf
Or simply add a fallback:
if (empty($content_disposition = $headers['Content-Disposition'] ?? [])) {
- last update
9 months ago 3 pass - Status changed to Needs review
9 months ago 2:03pm 28 February 2024