mercredi 3 juillet 2019

Retrieve video from Laravel Storage

Currently I am sending a video to the storage folder in Laravel through the following piece of code inside a create() function:

if ($request->hasFile('video_url')) {
    $video = $request->file('video_url');
    $folder = make_url($validated['title']);
    $video_name = time().'-vid.'. $video->getClientOriginalExtension();

    Storage::disk('local')->put('/uploads/' . $folder . '/', $video);

    $validated['video_url'] = $folder . '/' . $video->hashName();
}

It creates the video, send it to the proper folder and it sends the URL of the video to the database so that i can always retrieve the correct link. This all works fine.

I have no idea how to retrieve the video for playback from storage though.

I have tried to retrieve the link manually inside the video tags but, of course, the storage folder is not public so this did not work.





<video controls>

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

</video>

The var_dump gives me this:

/home/vagrant/code/storage/framework/views/777c4fe762b993d5be04ad6550ee11200bd4869d.php:49:string '���ftypmp42����mp42isomavc1����free�������������������������������������������������������������������������������������������������������������������������������mdat�� ���E���H��,� �#��x264 - core 79 - H.264/MPEG-4 AVC codec - Copyleft 2003-2009 - http://www.videolan.org/x264.html - options: cabac=0 ref=2 deblock=1:0:0 analyse=0x1:0x111 me=umh subme=6 psy=1 psy_rd=1.0:0.0 mixed_ref=1 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 chroma_qp_offset=-2 threads=6 nr=0 decimate=1 mbaff=0'... (length=383631)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire