get_bucket_object_count ( $bucket )

Gets the number of Amazon S3 objects in the specified bucket.

Access

public

Parameters

Parameter

Type

Required

Description

$bucket

string

Required

The name of the bucket to use.

Returns

Type

Description

integer

The number of Amazon S3 objects in the bucket.

Examples

Get the number of objects inside the bucket.

// Instantiate the class
$s3 = new AmazonS3();
$bucket = 'my-bucket' . strtolower($s3->key);

$response = $s3->get_bucket_object_count($bucket);

// Success?
var_dump($response);

Source

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

public function get_bucket_object_count($bucket)
{
    if ($this->use_batch_flow)
    {
        // @codeCoverageIgnoreStart
        throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
        // @codeCoverageIgnoreEnd
    }

    return count($this->get_object_list($bucket));
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback