php-general Digest 30 Sep 2013 18:03:46 - Issue 8383
Topics (messages 322219 through 36):
Re: delete S3 bucket with AWS PHP SDK
322219 by: Ashley Sheridan
31 by: Aziz Saleh
32 by: Tim Dunphy
33 by: Aziz Saleh
35 by: Tim Dunphy
Re: Switch Statement
30 by: mrfroasty
Re: Sending PHP mail with Authentication
34 by: Paul M Foster
Re: Is correct to override XML standards?
36 by: buzon.alejandro.ceballos.info
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
--
---BeginMessage---
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
Docshttp://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
---End Message---
---BeginMessage---
Hi Tim,
Is the call working? Does it actually get deleted?
This could just be an issue (which I see alot) where developers do not
check for variables or preset them before usage, causing those notices to
come up (pretty harmless most of the times).
Aziz
On Sun, Sep 29, 2013 at 12:30 PM, Tim Dunphy bluethu...@gmail.com 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