get_bucket_list ( $pcre )

Gets a simplified list of bucket names on an Amazon S3 account.

Access

public

Parameters

Parameter

Type

Required

Description

$pcre

string

Optional

A Perl-Compatible Regular Expression (PCRE) to filter the bucket names against.

Returns

Type

Description

array

The list of matching bucket names. If there are no results, the method will return an empty array.

Examples

Get the list of buckets in your account.

// Instantiate the class
$s3 = new AmazonS3();

$response = $s3->get_bucket_list();

// Success?
print_r($response);

Get the list of buckets in your account that match a PCRE regular expression pattern.

// Instantiate the class
$s3 = new AmazonS3();

// Only return the buckets with 'my-' in the name
$response = $s3->get_bucket_list('/my-/i');

// Success?
print_r($response);

See Also

Source

Method defined in services/s3.class.php | Toggle source view (19 lines) | View on GitHub

public function get_bucket_list($pcre = null)
{
    if ($this->use_batch_flow)
    {
        throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
    }

    // Get a list of buckets.
    $list = $this->list_buckets();
    if ($list = $list->body->query('descendant-or-self::Name'))
    {
        $list = $list->map_string($pcre);
        return $list;
    }

    // @codeCoverageIgnoreStart
    return array();
    // @codeCoverageIgnoreEnd
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback