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)
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);
No comments:
Post a Comment