mercredi 3 juillet 2019

Dynamic route to retrieve data from storage in Laravel

I am trying to retrieve a video from storage in Laravel. I have made a FileController that does the following:

class FileController extends Controller {

    function getVideo($video_name) {
        $video = Storage::disk('local')->get("uploads/{$video_name}");
        $response = Response::make( $video, 200 );
        $response->header( 'Content-Type', 'video/mp4' );

        return $response;
    }
}

Further on, the route that retrieves this function looks like this:

Route::get('/get-video/{video_name}', 'FileController@getVideo')->name('get-video');

Lastly, in my view, I am trying to retrieve the video:

<video controls>
    <source src="" type="video/mp4">
    Your browser does not support the video tag.
</video>

The video_url is stored in the database and corresponds with the video name and folder. These are correct, i have checked this. Also, if i hardcode the video URL instead of adding it dynamically, the video works fine.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2RSdWg6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire