From 19be7f13add42265eb85d6ad19c8a706f4360ad2 Mon Sep 17 00:00:00 2001 From: Moritz <46711821+MLDMoritz@users.noreply.github.com> Date: Thu, 27 Jul 2023 21:15:21 +0200 Subject: [PATCH] Add filename fallback for download --- src/VueFinder.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/VueFinder.php b/src/VueFinder.php index 9071cf4..f50a428 100755 --- a/src/VueFinder.php +++ b/src/VueFinder.php @@ -297,9 +297,15 @@ public function download() $path = $this->request->get('path'); $response = $this->streamFile($path); + $filenameFallback = preg_replace( + '#^.*\.#', + md5($path) . '.', $path + ); + $disposition = $response->headers->makeDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, - basename($path) + basename($path), + $filenameFallback ); $response->headers->set('Content-Disposition', $disposition);