PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Zend Framework 101: Zend_Service_Amazon_S3

Clearing and Removing Buckets

Clearing a bucket involves removing all objects that are stored within that bucket. This is achieved using the cleanBucket() method. This method accepts as its only argument the name of the bucket.

Buckets are removed using the removeBucket() method. This also accepts as its only argument the name of the bucket. You cannot delete a bucket while there are still objects in it, therefore, if you want to remove a bucket you should first clear it.

The following list demonstrates clearing then removing a bucket.

Listing 5 Clearing and removing a bucket (remove-bucket.php)
<?php
    require_once('Zend/Service/Amazon/S3.php');
 
    $awsKey       = '[your key]';
    $awsSecretKey = '[your secret key]';
 
    $s3 = new Zend_Service_Amazon_S3($awsKey, $awsSecretKey);
 
    $bucketName = 'phpriot-test-bucket';
 
    $s3->cleanBucket($bucketName);
    $s3->removeBucket($bucketName);
?>

In This Article



Bonus listings: 2 available