Fichier de téléchargement de Laravel S3
return Storage::download('file.jpg');
return Storage::download('file.jpg', $name, $headers);
TP
return Storage::download('file.jpg');
return Storage::download('file.jpg', $name, $headers);
$attachment = TicketAttachment::find($id);
$headers = [
'Content-Type' => 'application/jpeg',
'Content-Disposition' => 'attachment; filename="'. $attachment->name .'"',
];
return \Response::make(Storage::disk('s3')->get($attachment->url), 200, $headers);
public function downloadAsset($id)
{
$asset = Asset::find($id);
$assetPath = Storage::disk('s3')->url($asset->filename);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=" . basename($assetPath));
header("Content-Type: " . $asset->mime);
return readfile($assetPath);
}