From ad08cf4255ca6506c2b13ec20ace2ba05fc808aa Mon Sep 17 00:00:00 2001 From: Baspa Date: Fri, 3 Jan 2025 11:40:44 +0100 Subject: [PATCH] Fix downloading attachments --- src/Controllers/MailDownloadController.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Controllers/MailDownloadController.php b/src/Controllers/MailDownloadController.php index 05c1a32..49b5813 100644 --- a/src/Controllers/MailDownloadController.php +++ b/src/Controllers/MailDownloadController.php @@ -2,20 +2,25 @@ namespace Vormkracht10\FilamentMails\Controllers; -use Illuminate\Http\Request; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Storage; use Vormkracht10\Mails\Models\MailAttachment; class MailDownloadController extends Controller { - public function __invoke(Request $request) + public function __invoke(string $tenant, string $mail, string $attachment, string $filename) { /** @var MailAttachment $attachment */ - $attachment = MailAttachment::find($request->attachment); + $attachment = MailAttachment::find($attachment); - $file = Storage::disk($attachment->disk)->get($attachment->uuid); + $file = Storage::disk($attachment->disk)->path($attachment->uuid); - return response()->download($file); + return response()->download( + file: $file, + name: $filename, + headers: [ + 'Content-Type' => $attachment->mime, + ] + ); } -} +} \ No newline at end of file