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.
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.
This solution maintains an index in an Apache Parquet file, which optimizes Athena queries to search Amazon S3 metadata. Using this approach makes it straightforward to run queries as needed without the need to ingest data or manage any servers.
You can set object metadata in Amazon S3 at the time you upload the object. Object metadata is a set of name-value pairs. After you upload the object, you cannot modify object metadata.
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 name of the bucket that you want to view the properties for. Choose Properties. On the Properties page, you can configure the following properties for the bucket.
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
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