Hi i am moving my local Laravel images to aws when I retrieve the local files it brings back the file correctly however when i retrieve the aws file it comes back as serialized
this is my function i have to retrieve images

The first if block where it return the images comes back as an image:
However when I retrieve the file and return it from AWS it comes back as:
Am I retrieving the image from aws wrong, still new to this :D.
CodePudding user response:
Onces you have s3 configured in your storage, you can save a file like this:
$url = $file->store($path, 's3');
Or
Storage::disk('s3')->put($path.'/'.$filename, $imageFile);
And you can get this image like this:
$url = Storage::disk('s3')->url($path);
Or if you want to have this safety option, that a link is valid only for a couple of minutes:
$url = Storage::disk('s3')->temporaryUrl(
$path, Carbon::now()->addMinutes(60)
);
The key is, when you use AWS, you should not try to get the image it self, but a link to that image through aws. Also you should store this url into the database not the image itself. And you should display the image through that link.


