简体   繁体   中英

No buckets list amazon aws s3 with aws-sdk-php?

I am able to connect AWS s3 with Cyberduck using my KEY/Secret and PATH, and also able to see my files in there. But when I try to connect using the PHP Api and list the buckets I got 0 results. I noticed there is no path variable S3Client (would this make any difference?) Asking because if I don't use PATH in Cyberduck I can't see the files.

$s3 = new Aws\S3\S3Client([
        'version' => 'latest',
        'region'  => 'us-east-1',
        'credentials' => [
                'key'    => 'KEY',
                'secret' => 'SECRET',
        ],
]);

And when I do:

$result = $s3->listBuckets();
var_dump($result);

Return is: ("REMOVED" was removed here by myself.)

object(Aws\Result)#78 (1) {
  ["data":"Aws\Result":private]=>
  array(3) {
    ["Buckets"]=>
    array(0) {
    }
    ["Owner"]=>
    array(2) {
      ["DisplayName"]=>
      string(8) "REMOVED"
      ["ID"]=>
      string(64) "REMOVED"
    }
    ["@metadata"]=>
    array(4) {
      ["statusCode"]=>
      int(200)
      ["effectiveUri"]=>
      string(25) "https://s3.amazonaws.com/"
      ["headers"]=>
      array(6) {
        ["x-amz-id-2"]=>
        string(76) "REMOVED="
        ["x-amz-request-id"]=>
        string(16) "REMOVED"
        ["date"]=>
        string(29) "Mon, 29 Jan 2018 18:04:57 GMT"
        ["content-type"]=>
        string(15) "application/xml"
        ["transfer-encoding"]=>
        string(7) "chunked"
        ["server"]=>
        string(8) "AmazonS3"
      }
      ["transferStats"]=>
      array(1) {
        ["http"]=>
        array(1) {
          [0]=>
          array(0) {
          }
        }
      }
    }
  }
}

I tried to figure out by reading the AWS S3 documentation, but I only found way to list the files using bucket option, but I don't know what is the bucket name. And my return when list for bucket names is 0. But all files are there. Am I doing something wrong?

(Posted on behalf of the question author to move their answer to the answers section) .

This is not a AWS S3 issue. I found it was a permission issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM