lundi 24 août 2015

Amazon S3 how to validate Access Key Id and Secret Access Key? PHP SDK v3

I'm trying to catch wrong secret key exception on registerStreamWrapper, and it is just not happening.

My problem is originated when trying to verify if object exists, if anyone call help me with this(best way to do it), would be awesome, but this is another issue. Back to the problem.

I'm using this code to check if object exists using registerStreamWrapper:

try{
        $s3Client = new \Aws\S3\S3Client($sharedConfig);
        $s3Client->registerStreamWrapper();
        $file = 's3://'."mybucket".'/'."testpath/testpic.jpg";

        if(file_exists($file)){
            echo "true";
        }else{
            echo "false";
        }

    } catch (S3Exception $e) {
        // Catch an S3 specific exception.
        echo $e->getMessage();
    } catch (AwsException $e) {
         // This catches the more generic AwsException. You can grab information
        // from the exception using methods of the exception object.
        echo $e->getAwsRequestId() . "\n";
        echo $e->getAwsErrorType() . "\n";
        echo $e->getAwsErrorCode() . "\n";
    }

If I provide wrong secret key, it just returns false. Is there anyway to validate access key id and secret access key? This would make my life so easy.

Can't find anything here : http://ift.tt/1WOMVad or here: http://ift.tt/1LKnn7j




Aucun commentaire:

Enregistrer un commentaire