On Sun, 2013-09-29 at 12:30 -0400, Tim Dunphy wrote:

> Hi All,
> 
>  I am attempting to delete an empty S3 bucket using the AWS PHP SDK.
> 
>  Here's how they describe the process in the docs:
> 
> $result = $client->deleteBucket(array(
>     // Bucket is required
>     'Bucket' => 'string',
> ));
> 
>  You can find the full entry here:
> 
> AWS PHP SDK Delete Bucket
> Docs<http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_deleteBucket>
> 
> Here's how I approached it in my code:
> 
>  $s3 = new AmazonS3();
> 
>   $result = $s3->deleteObject(array(
>     'Bucket' => $bucket_name ));
> 
> But when I run it, this is the error I get:
> 
> 'Notice: Undefined index: $bucket_name in /var/www/awssdk/delete_bucket.php
> on line 5 Warning: Missing argument 2 for AmazonS3::delete_object() in
> /var/www/awssdk/services/s3.class.php on line 1576 Notice: Undefined
> variable: filename in /var/www/awssdk/services/s3.class.php on line 1581
> Warning: preg_match() expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1042 Warning: preg_match()
> expects parameter 2 to be string, array given in
> /var/www/awssdk/services/s3.class.php on line 1043 Fatal error: Uncaught
> exception 'S3_Exception' with message 'S3 does not support "Array" as a
> valid bucket name. Review "Bucket Restrictions and Limitations" in the S3
> Developer Guide for more information.' in
> /var/www/awssdk/services/s3.class.php:548 Stack trace: #0
> /var/www/awssdk/services/s3.class.php(1594): AmazonS3->authenticate(Array,
> Array) #1 [internal function]: AmazonS3->delete_object(Array) #2
> /var/www/awssdk/sdk.class.php(436): call_user_func_array(Array, Array) #3
> /var/www/awssdk/delete_bucket.php(10): CFRuntime->__call('deleteObject',
> Array) #4 /var/www/awssdk/delete_bucket.php(10):
> AmazonS3->deleteObject(Array) #5 {main} thrown in
> /var/www/awssdk/services/s3.class.php on line 548'
> 
> 
> This is line 548 in the above referenced file:
> 
> // Validate the S3 bucket name
>                 if (!$this->validate_bucketname_support($bucket))
>                 {
>                         // @codeCoverageIgnoreStart
>                         throw new S3_Exception('S3 does not support "' .
> $bucket . '" as a valid bucket name. Review "Bucket Restrictions and
> Limitations" in the S3 Developer Guide for more information.');
>                         // @codeCoverageIgnoreEnd
>                 }
> 
> 
> 
> 
> Has anyone played around enough with the AWS SDK to know what I'm doing
> wrong here? Would anyone else be able to hazard a guess?
> 
> Thanks
> Tim


Your code is failing because $bucket_name, I suspect, is null. Where do
you define this variable before you use it in this bit of code:

$result = $s3->deleteObject(array(
    'Bucket' => $bucket_name ));

Thanks,
Ash
http://www.ashleysheridan.co.uk


Reply via email to