26 lines
733 B
PHP
26 lines
733 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Domain\Catalog\ContentElement;
|
|
use App\Domain\Media\WebsiteMedia;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
|
|
|
class WebsiteMediaController extends Controller
|
|
{
|
|
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
|
{
|
|
$presentation = $media->present($element);
|
|
abort_if($presentation === null, 404);
|
|
|
|
$path = $element->website_public_path;
|
|
abort_if(! is_string($path), 404);
|
|
|
|
return Storage::disk('media_public')->response($path, null, [
|
|
'Content-Disposition' => 'inline',
|
|
'X-Content-Type-Options' => 'nosniff',
|
|
]);
|
|
}
|
|
}
|