22 lines
627 B
PHP
22 lines
627 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Http\Controllers;
|
||
|
|
|
||
|
|
use App\Models\Asset;
|
||
|
|
use App\Models\VideoProject;
|
||
|
|
use Illuminate\Support\Facades\Storage;
|
||
|
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||
|
|
|
||
|
|
class VideoProjectAssetController extends Controller
|
||
|
|
{
|
||
|
|
public function show(VideoProject $videoProject, Asset $asset): StreamedResponse
|
||
|
|
{
|
||
|
|
abort_if($asset->video_project_id !== $videoProject->id, 404);
|
||
|
|
abort_unless(Storage::exists($asset->disk_path), 404);
|
||
|
|
|
||
|
|
return Storage::response($asset->disk_path, null, [
|
||
|
|
'Content-Type' => $asset->mime_type ?: 'application/octet-stream',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
}
|