0

I'm attempting to list the files in my S3 bucket but I keep getting a PHP Error when running this code:

require_once './S3.php';

define('awsAccessKey', 'xxx');
define('awsSecretKey', 'xxx');
$s3 = new S3(awsAccessKey, awsSecretKey);
$objects = $s3->list_objects("BUCKETNAME",array("max-keys"=>5));
foreach ($objects->body->Contents as $item){
    print_r($item->Key."");
}

I get:

PHP Fatal error:  Call to undefined method S3::list_objects()

Google isn't helping me. I can put files in my bucket but I can't list them. Any ideas?

2 Answers 2

1

Well, the obvious answer is that the (third-party; not from Amazon) S3 class doesn't have a list_objects() method.

This class does, however, have a getBucket() method that probably does the same thing.

If you meant to use the official AWS SDK for PHP 1.x, you'd look at the AmazonS3::list_objects() method.

If you want to use something current and supported (i.e., AWS SDK for PHP 2.x), you'd look at the S3Client::listObjects() method.

Sign up to request clarification or add additional context in comments.

Comments

0

Am using this library https://github.com/aws/aws-sdk-php. A properly maintained source.

The function you are looking for can be called as S3->listObjects() using this library

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.