exists($cleanPath)) { abort(404); } $file = $disk->get($cleanPath); if ($file === null) { abort(404); } $contentType = match (strtolower(pathinfo($cleanPath, PATHINFO_EXTENSION))) { 'jpg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'webp' => 'image/webp', 'gif' => 'image/gif', 'svg' => 'image/svg+xml', default => 'application/octet-stream', }; return response($file, 200, [ 'Content-Type' => $contentType, 'Cache-Control' => 'public, max-age=31536000, immutable', ]); } }