php - Laravel - Can't save file from Disk to database record

I'm using S3 to store my files. I have a video saved in my directory. I want to take the video from S3 and save it to a record in my DB. This is the code I'm using:
$file = Storage::get('input/TESTING.mp4');
$newer->video = $file;
I'm getting this error (which comes from the second line of my code):
file_exists() expects parameter 1 to be a valid path, string given
The file does exist, I'm 100% sure, Laravel is finding it. I used the Storage::exists() function to test that.
I'm not sure what the problem is, any help would be appreciated.
Answer
Solution:
The methodStorage::get
returns the content of the file and not the location. You can see it on the documentation.
To get the path, you should do something like that:
$path = Storage::disk('local')->getDriver()->getAdapter()->applyPathPrefix('filename.png');
Or, since Laravel 5.4:
$path = Storage::disk('public')->path('filename.png');
More details:
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: gd library extension not available with this php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.