Gets a list of all Amazon S3 objects in the specified bucket.
NOTE: This method is paginated, and will not return more than max-keys
keys. If you want to retrieve a list of all keys, you will need to make multiple calls to this function using the marker
option to specify the pagination offset (the key of the last processed key—lexically ordered) and the IsTruncated
response key to detect when all results have been processed. See: the S3 REST documentation for get_bucket for more information.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The name of the bucket to use. |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
List all objects inside a bucket.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); $response = $s3->list_objects($bucket); // Success? var_dump($response->isOK());Result:
bool(true)
List all objects inside a bucket that match the parameters given.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); $response = $s3->list_objects($bucket, array( 'prefix' => 'word/', 'max-keys' => 1 )); // Success? var_dump($response->isOK()); var_dump(count($response->body->Contents))Result:
bool(true) int(1)
List all objects inside a bucket that match the parameters given. Supports UTF-8 characters.
// Instantiate the class $s3 = new AmazonS3(); $bucket = 'my-bucket' . strtolower($s3->key); $response = $s3->list_objects($bucket, array( 'delimiter' => '/', 'marker' => 'mårkér wîth spåcés ånd întl' )); // Success? var_dump($response->isOK());Result:
bool(true)
Source
Method defined in services/s3.class.php | Toggle source view (19 lines) | View on GitHub