I am working with an s3 bucket in laravel (11) and have following function in my controller to dowload a given file to chrome:
public function downloadFile(Materials $material)
{
Gate::authorize('view', $material);
$fileInfo = pathinfo($material->filename);
$filename = urlencode($material->name) . "." . $fileInfo['extension'];
return Storage::disk('s3')->response( $material->filename, $filename );
}
The problem is, that the file does not have the filename in $filename after the download. It is the hash from s3.
But the header seems ok?
Content-Disposition:
inline; filename="DatenschutzerklC3A4rung+Muster.docx"; filename*=utf-8''Datenschutzerkl%25C3%25A4rung%2BMuster.docx
What I also tried so far is:
# number 1
return Storage::disk('s3')->response(
$material->filename,
urldecode($filename),
['Content-Disposition' => 'attachment']
);
# number 2
return Storage::disk('s3')->response(
$material->filename,
$filename,
['Content-Disposition' => "attachment; filename=\"$filename\"; filename*=UTF-8''$filename"]
);
But no Luck ... did I get something wrong?