Invalid handle provided

0

My code is as follows: require 'vendor/autoload.php'; use Aws\S3\S3Client; $region = 'ap-south-1'; $version = 'latest'; $s3Client = S3Client::factory(array( 'credentials' => array( 'key' => 'MY_KEY', 'secret' => 'MY_SECRET', ), 'region' => $region, 'version' => $version, 'profile' => 'default' ));

If I try any method like createBucket or listBuckets on object "s3Client" above, it just throws the error "Invalid handle provided". If i do var_dump($s3Client), it gives the proper object with all properties and methods. Am I missing something?

  • Just to answer my own query, the issue was due to PHP version 8. I have downgraded it to PHP 7.3 and the error is gone. Thanks guys

lkpatir
asked a year ago363 views
1 Answer
0

I noticed that you're using both 'credentials' and 'profile' in your S3Client configuration. The 'profile' option is used to specify a profile in your AWS credentials file, and the 'credentials' option is used to specify your AWS credentials directly. You should use one or the other, not both. If you're providing your AWS credentials directly in your code, you should remove the 'profile' option.

AWS
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions