14

I've been looking through all the docs for AWS SDK PHP and I can't see a way to retrieve an object's meta data. I can retrieve the Key, Size, Last Modified, etc; but I don't see an example in the docs for how to get the metadata.

jpschroeder
  • 6,636
  • 2
  • 34
  • 34
Francis Baptiste
  • 455
  • 5
  • 13
  • Hi, i have the same issue in finding metadata like getting list of image names under a path. Do you find the solution? Can you help me? Thanks in advance – Sakthimuthiah Dec 02 '14 at 06:15
  • Unfortunately, no, I never did find an answer to this. – Francis Baptiste Dec 22 '14 at 18:15
  • Review my answer on a similar question here; if that works for you, I'll be glad to add it as the answer to this question. http://stackoverflow.com/questions/32191946/retrieve-object-user-metadata-in-s3-aws-sdk-v3-php/32344870#32344870 – Andrew Bucklin Sep 02 '15 at 04:58

1 Answers1

10

The call you're looking for is headObject. According to the docs: The HEAD operation retrieves metadata from an object without returning the object itself. This operation is useful if you're only interested in an object's metadata. To use HEAD, you must have READ access to the object.

Here is the example call from the version 3 sdk (this is such an old post I assume version 3 would be used now instead of version 2, but both SDKs include this call)

$result = $client->headObject([
    'Bucket' => '<string>', // REQUIRED
    'IfMatch' => '<string>',
    'IfModifiedSince' => <integer || string || DateTime>,
    'IfNoneMatch' => '<string>',
    'IfUnmodifiedSince' => <integer || string || DateTime>,
    'Key' => '<string>', // REQUIRED
    'Range' => '<string>',
    'RequestPayer' => 'requester',
    'SSECustomerAlgorithm' => '<string>',
    'SSECustomerKey' => '<string>',
    'SSECustomerKeyMD5' => '<string>',
    'VersionId' => '<string>',
]);

SDK Documentation

jpschroeder
  • 6,636
  • 2
  • 34
  • 34