'How can I get file metadata like the date created attribute from an S3 file?

I have a lot of LogicPro files (.logicx) stored in an S3 bucket, and I want to extract the creation date from all of these files. This should not be the creation date of the object on s3, but the date for when it was created on my MacBook (the "Created" attribute in Finder).

I've tried to retrieve the metadata from the object using the HEAD action:

aws s3api head-object --bucket <my-bucket> --key <my-object-key>

The output did not contain any information about the creation date of the actual file.

{
   "AcceptRanges":"bytes",
   "LastModified":"2021-10-28T13:22:33+00:00",
   "ContentLength":713509,
   "ETag":"\"078c18ff0ab5322ada843a18bdd3914e\"",
   "VersionId":"9tseZuMRenKol1afntNM8mkRbeXo9n2W",
   "ContentType":"image/jpeg",
   "ServerSideEncryption":"AES256",
   "Metadata":{},
   "StorageClass":"STANDARD_IA"
}

Is it possible to extract the file creation metadata attribute from an S3 object, without having to download the whole object?



Solution 1:[1]

Is it possible to extract the file creation metadata attribute from an S3 object, without having to download the whole object?

No, unfortunately.

To obtain metadata within the object itself like the data created attribute, you will need to download the entire file first. Amazon S3 does not store this information as it is more of an object store than a file storage service. It only sets & stores system-defined object metadata determined by S3, by default.

You could try extracting it before uploading & setting it as user-defined object metadata which would then be returned in the Metadata field above, or try to see if you can obtain what you need from a pre-defined byte range via byte-range fetches (essentially a HTTP range request).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1