Using javascript and AWS Amplify, I am trying to attach some custom metadata to files that are uploaded to my s3 bucket. Most of the available options are not described in the documentation, but after digging around the source code I found that adding, for example, {metadata: { 'your-custom-key-1': 'foo', 'your-custom-key-2': 'bar' }
as the options paramter in Storage.put() will automatically create custom metadata on your file, which automatically prefixes your custom keys with 'x-amz-meta-'. So in the above case, you have 'x-amz-your-custom-key-1': 'foo', 'x-amz-your-custom-key-2': 'bar'
as the actual metadata attached and saved to that specific files.
The issue is, as far as I can tell, I do not see any way to retrieve this metadata using amplify. I presume I would have to dig a layer deeper into the core s3 class to retrieve this information. To make matters even more confusing...I've found that with amplify, if I call Storage.get() with the hidden option { download: true} as my option parameter, I get back a response that actually has a Metadata key, however it is always empty, even when I certainly do have custom metadata attached to my file. I'm guessing this a feature that has either been changed or is incomplete? Looking into the core s3 class, I found the headObject
, but I am not clear whether this would give me my custom metadata or just the default. My end goal is to list all of the associated metadata with all files in my bucket when I call Storage.list(). Thanks for any advice