Skip to content

Commit

Permalink
Fix downloading attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Jan 3, 2025
1 parent 1904b08 commit ad08cf4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Controllers/MailDownloadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
);
}
}
}

0 comments on commit ad08cf4

Please sign in to comment.