23 lines
567 B
PHP
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);
|
|
}
|
|
}
|