새 버켓을 만들지 않으면 특정 버킷이 있는지 확인하고 싶습니다.이미 존재하지 않는 경우 버킷을 생성합니다.
내가 버킷 이미 aws.phar + PHP는 여기에를 사용하여 존재하는 경우 나에서 감지 할 수있는 방법을 알아야
는 의사 코드
$bucket = 'my-bucket';
//some code to detect if bucket name 'my-bucket' exists *suggest here*
//$myBucketExists = $client->someMethode()
if(!$myBucketExists){
$result = $client->createBucket(array(
'Bucket' => $bucket
));
// Wait until the bucket is created
$client->waitUntil('BucketExists', array('Bucket' => $bucket));
}
// rest of the code using the bucket
[doesBucketExists()] (http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_doesBucketExist) 도우미 메서드가 있습니다. headBucket. –
with headBucket() 메서드 버킷 doen't가있는 경우 headBucket에서 예외를 throw하므로 catch 블록에 새 버킷 생성 코드를 작성해야합니다. 이렇게하면 작동합니다. Thanks @Nadh – veer7
doesBucketExist()는 훌륭합니다. 두 가지 방법 모두 잘 작동하며 최선의 코딩 방법으로 doesBucketExist()를 선호합니다. 감사합니다 @ 제레미 린 블럼 – veer7