I am using amazon s3 v3 php sdk and i am trying to get key of all object for that i am using
s3->listObjects([ 'Bucket' => $somebucketName]);
this function is working fine and i am getting all object under $somebucketName
bucket and its in below form
Aws\Result Object
(
[data:Aws\Result:private] => Array
(
[IsTruncated] =>
[Marker] =>
[Contents] => Array
(
[0] => Array
(
[Key] => 1.PNG
[LastModified] => Aws\Api\DateTimeResult Object
(
[date] => 2015-07-14 07:22:25.000000
[timezone_type] => 2
[timezone] => Z
)
[ETag] => "23f423234v23v42424d23"
[Size] => 19980
[StorageClass] => STANDARD
[Owner] => Array
(
[DisplayName] => sfsfssfsdf
[ID] => 242f2342242342252g42f42vt34
)
)
[1] => Array
(
[Key] => 58.jpg
[LastModified] => Aws\Api\DateTimeResult Object
(
[date] => 2015-07-14 07:20:26.000000
[timezone_type] => 2
[timezone] => Z
)
[ETag] => "vrtet4v4t54tvt4gvtgv45"
[Size] => 1226694
[StorageClass] => STANDARD
[Owner] => Array
(
[DisplayName] => sfsfssfsdf
[ID] => 34t3t3t3y43y4yg5yy4vg6u676
)
)
[2] => Array
(
[Key] => HDFHDFHDFHDFHFHFH
[LastModified] => Aws\Api\DateTimeResult Object
(
[date] => 2015-07-30 12:07:42.000000
[timezone_type] => 2
[timezone] => Z
)
[ETag] => "3453345343rcf3f3r3r3f"
)
[Name] => SFSSD
[Prefix] =>
[MaxKeys] => 1000
[@metadata] => Array
(
[statusCode] => 200
[effectiveUri] => https://s3-us-west-2.amazonaws.com/SFSSD
[headers] => Array
(
[x-amz-id-2] => sdfsfs234sfs
[x-amz-request-id] => HSJFSD899
[date] => Mon, 03 Aug 2015 06:46:48 GMT
[x-amz-bucket-region] => us-west-2
[content-type] => application/xml
[transfer-encoding] => chunked
[server] => AmazonS3
)
)
)
)
now my question is that how to get array of key like below from above object
array("1.png","58.jpg","HDDHDFHDHDGH);
Sign in to the AWS Management Console and open the Amazon S3 console at https://console.aws.amazon.com/s3/ . In the Buckets list, choose the bucket that you want to enable an S3 Bucket Key for. Choose Properties. In the Default encryption section, under Bucket Key, you see the S3 Bucket Key setting for your bucket.
In the Amazon S3 console, choose your S3 bucket, choose the file that you want to open or download, choose Actions, and then choose Open or Download. If you are downloading an object, specify where you want to save it. The procedure for saving the object depends on the browser and operating system that you are using.
The object key (or key name) uniquely identifies the object in an Amazon S3 bucket. Object metadata is a set of name-value pairs. For more information about object metadata, see Working with object metadata. When you create an object, you specify the key name, which uniquely identifies the object in the bucket.
Aws\Result
implements ArrayAccess
. You can access the contents like so:
$result = $s3->listObjects(['Bucket' => $somebucketName])
$contents = $result['Contents'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With