I started use an S3 bucket in my Laravel 8.x
project, and I solved file uploads to the bucket with this code:
Storage::disk('s3')->put($file_path_on_s3_drive, $file_content_as_binary);
Now I try to serve this image to the browser like this:
public function showImage(string $id) {
$image = Image::find($id);
return Storage::disk('s3')->get($image->file_path_on_s3_drive);
}
But it shows the file as string in the browser and not as image.
How can show the data as image in the browser?
UPDATE:
I call this showImage()
function from a web route:
Route::get('image/{id}', [ImageController::class, 'showImage']);
The soultion was: