get_bucket_tags ( $bucket, $opt )

Retrieve all associated tags for the specified bucket.

Access

public

Parameters

Parameter

Type

Required

Description

$bucket

string

Required

The name of the bucket to use.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Create, get and delete bucket tags.

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

#--------------------------------------------------------------------#
# Create a new bucket

$response = $s3->create_bucket($bucket, AmazonS3::REGION_US_STANDARD);

if ($response->isOK())
{
	// Give the bucket a moment to create
	while (!$s3->if_bucket_exists($bucket))
	{
		sleep(1);
	}
}

#--------------------------------------------------------------------#
# Create new bucket tags

$response = $s3->create_bucket_tags($bucket, array(
	'tags' => array(
		'project' => 'foo',
		'user'    => 'bar',
	)
));

if ($response->isOK())
{
	// Give the configuration a moment to settle in
	while (!$s3->get_bucket_tags($bucket)->isOK())
	{
		sleep(1);
	}
}

#--------------------------------------------------------------------#
# Retrieve the bucket tags

$response = $s3->get_bucket_tags($bucket);
print_r($response->body);
echo PHP_EOL;

#--------------------------------------------------------------------#
# Delete the bucket tags

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

if ($response->isOK())
{
	// Delete the bucket
	$response = $s3->delete_bucket($bucket, true);

	if ($response->isOK())
	{
		echo 'Bucket was deleted!' . PHP_EOL;
	}
	else
	{
		echo 'Bucket deletion failed. #sadtromboneissad' . PHP_EOL;
	}
}

Source

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

public function get_bucket_tags($bucket, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['verb'] = 'GET';
    $opt['sub_resource'] = 'tagging';
    $opt['headers'] = array(
        'Content-Type' => 'application/xml'
    );

    // Authenticate to S3
    return $this->authenticate($bucket, $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback