M
M
Mokhirjon Naimov2016-06-26 15:48:31
Laravel
Mokhirjon Naimov, 2016-06-26 15:48:31

How to play video from storage folder in Laravel?

I store files in a folder storageto get photos using a package league/glide, that is, in the tag <img>I specify the route that works with photos. But what about the video, is there a simple solution?
The problem is that only the publicfolder is available from the Internet, and the folder storageis closed like others...
UPD:
sim3x In general, everyone, I just can't specify <source src="/storage/file.mp4" type="video/mp4">
`storage`, the folder is not available...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrzej Wielski, 2016-06-27
@zvermafia

Create a route that will provide the necessary files on request.
Something like this:

Route::get('/videos/{filename}', function($filename){
    $file = Storage::get('videos/'.$filename);
    $mimetype = Storage::mimeType('videos/'.$filename);
    return response($file, 200)->header('Content-Type', $mimetype);
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question