0
votes

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?

1
Are you certain your bucket(s) are in the us-east-1 region?ceejayoz
path is: /logstorage-us-east-1 .. so, I suppose so . Is there an way to verify? @ceejayozigtoth
That path doesn't mean anything - you could put a "folder" in a eu-west-2 bucket called that. Take a look in your AWS Console. "Path" should be completely meaningless to the S3 listBuckets command.ceejayoz
I don't have access to this AWS console.. I got only the Key/Secret to access some log filesigtoth
You might not have access to listBuckets then. Either way, ask the person who manages the key/secret.ceejayoz

1 Answers

0
votes

(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.