2amigos / yiiaws

Amazon Web Services SDK PHP 2 Wrapper
21 stars 15 forks source link

Using S3 "doesBucketExist" does not work #15

Closed stringbeans closed 11 years ago

stringbeans commented 11 years ago

In my case, we're trying to use "doesBucketExist" which has the following signature: public boolean doesBucketExist( string $bucket, boolean $accept403 = true, array $options = array() )

However, looking at your implementation of __call in A2Base.php, the getCommand function from the client assumes that the command args will be an array, which in this case may not be.

Moreover, if the correct array is passed in, there is an error of 'Command was not found matching doesBucketExist'.

Out of curiosity, why do you getCommand and execute when we could just directly make calls to the client?

tonyguillen commented 11 years ago

I was banging my head on this for a few days. Here is a wrapper function for object exists which has the same problem as not being a recognized function in the S3 class, but of course part of the aws library.

static function S3FileExists ($bucket, $key) {
    $s3 = new A2S3();
    try {
        $response =  $s3->getClient()->doesObjectExist((string) $bucket, (string) $key);
    }

    catch (Aws\S3\Exception\S3Exception $e) {
        Yii::trace($e->getResponse()->getStatusCode(), "error");
        return false;
        Yii::app()->end();
    }

}
tonydspaniard commented 11 years ago

Thank you very much @tonyguillen