I've only done this once, so there may be other ways, but how we did it was to set up Cloudfront and just access it via a URL.
Another dev in the team set that bit up, but that was what worked for us.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone,
I am struggling with finding the right way to stream videos from my S3 disk. I uploaded video files (*.webm) to my S3 disk with
Storage::disk('s3')->put('/videos/ABC.webm', File::get($videoTempPath));
The upload works fine. I now wonder what is the best way to display the videos in a HTML5 Player. I am using vue.js in the frontend (a single page app) and no Blade templates.
I know I could access the file directly on S3 like this: https://s3-eu-west-1.amazonaws.com/my-bucket/videos/ABC.webm
but I would like to define a route like http://myapp.dev/media/video/ABC to get the video.
I defined a route and a Controller with the function:
public function getVideo(Request $request, $downloadCode) {
...
}
What is the best way to stream the video to the client in a performant and right way?
I could just use return Storage::disk('s3')->get('/videos/ABC.webm'); but this would load the entire file to memory and then return it, right?
I tried some stuff with StreamedResponse like
$stream = Storage::disk('s3')->getDriver()->readStream($path);
$response = new StreamedResponse(function() use ($stream) {
echo stream_get_contents($stream);
});
But I don't know if this is the right way? Is this really streaming the content?
Thanks for your help,
Robert
Please or to participate in this conversation.