Files
laraundfelix/app/Http/Controllers/PublicMediaController.php
LarsandCursor 2035c46edd
Deploy Test / test (push) Successful in 2m25s
Deploy Test / deploy (push) Failing after 25s
Stelle das U0-Fundament mit CMS, Mitgliedern und Filament bereit.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 08:32:14 +01:00

23 lines
567 B
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;
class PublicMediaController extends Controller
{
public function show(string $path): StreamedResponse
{
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
foreach (['media_public', 'cms_incoming'] as $disk) {
if (Storage::disk($disk)->exists($path)) {
return Storage::disk($disk)->response($path);
}
}
abort(404);
}
}