MajesticOverlord
MajesticOverlord

Reputation: 101

How do I list objects from public AWS S3 buckets using aws-sdk-php (v3.305.1) using anonymous clients?

So I have a public bucket which can directly be access by a link (can see the data if I copy paste that link on the browser).

However, when I try access the bucket via aws-sdk-php (v3.305.1) library it gives me the error:

"The authorization header is malformed; a non-empty Access Key (AKID) must be provided in the credential."

This is the code I have written to access the objects of my public bucket:

$s3Client = new S3Client([
   "version" => "latest"
   "region" => "us-east-1"
   "credentials" => false // since its a public bucket
]);

$data = $s3Client->listObjectsV2([
   "bucket" => "my bucket name"
]);

As per the AWS Documentation it says this it using the code above so I am not really sure why I am getting the error.

So how do I go about fixing this error ?

Upvotes: 1

Views: 108

Answers (0)

Related Questions