Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dargue3's avatar

Storage::get( ) using Amazon S3 returns false

Combining both Intervention Image and Amazon S3, I'd like to be able to pull a file from S3 and then use Image to do some cropping. This is what I have so far, why does Storage::get() return false?

$path = 'uploads/pics/123.jpeg';
    
$exists = Storage::disk('s3')->exists($path); // returns true

$image = Storage::disk('s3')->get($path);    // returns false
0 likes
10 replies
ejdelmonico's avatar

Is the visibility marked "public"?

$visibility = Storage::getVisibility('file.jpg');
ejdelmonico's avatar

So, just thinking out loud, if the get() method retrieves the contents of a file, why is it returning false instead of NULL?

ejdelmonico's avatar

vendor/league/flysystem/src/Filesystem.php is where I find all of the methods. There are many others that may work. The get() method is returning $handler and not the contents as the docs would lead you to believe I'm guessing. You might want to try using the read() method to see if you even get the image from S3.

dargue3's avatar

I'm really not sure, there's only one line dedicated to this in the docs, and through googling the problem I've come up with nothing. Most likely something to do with the permissions in S3... however those seem to be set well.

dargue3's avatar

I've tried read(), I've tried readStream(); they both return false

If I do getMetaData() I do indeed see all the correct data about the image.

ejdelmonico's avatar

Hmm, those two should return an object unless the object is false...then returns false. Which system are you using? League\Flysystem or another?

dargue3's avatar

League\Flysystem yes, with their AWS-S3 adaptor. It seems as though every other command, put(), url(), exists(), getMetaData() all work, it's just the GET commands that aren't working. And seeing how I can go and visit the S3 URL straight from a browser, I imagine the permissions are wide open

ejdelmonico's avatar

Yea, I don't have any projects right now where I can give it a whirl. If I get some extra time, I will try it out. I only store Avatars in one of my projects and I do that locally since the images are small.

jonathanmartins's avatar

After digger deeper into the code I found this message:

"Error executing "GetObject" on "file"; AWS HTTP error: file_exists(): open_basedir restriction in effect. File(/etc/pki/tls/certs/ca-bundle.crt) is not within the allowed path(s): (paths)"

First it seems that my server don't have this file, but it have! The file is located in another folder: /etc/ssl/certs/ca-certificates.crt

So, to solve my problem in Ubuntu I have to create this folder, "/etc/pki/tls/certs" and after that, symlink to the correct file, like so:

cd /etc/pki/tls/certs; sudo ln -s /etc/ssl/certs/ca-certificates.crt ca-bundle.crt;

Edit your "php.ini" and add "/etc/pki/tls/certs/ca-bundle.crt" to the "open_basedir" configuration.

Restart your php server!

For me it solves the problem, hope it helps!

Please or to participate in this conversation.