I need to update the cache control header in all AmazonS3's Cloud Files. However, I can't figure out how I do that using the jclouds API. I'm using apache jclouds plugin. And I got two related answers:
- jclouds : how do I update metadata for an existing blob?
- Set Expires header for an existing S3 object using AWS Java SDK
The first answer is suggesting to use SwiftKey Api class which is not available in grails's jcloud plugin. The second answer is using AWS java sdk for which there is already a grails wrapping plugin https://grails.org/plugin/aws-sdk but it doesn't support metadata update.
As at March 2018, the latest version of the AWS SDK for .NET Core has changed. It now uses asynchronous programming. Many of the method signatures have changed. While you still cannot change metadata without the object copy solution that Dan has suggested, the code to do so has.
My solution is to update the existing S3 object with the modified metadata.
The following works for me to update a single metadata value (based on key and new value). I've got two loops for setting the metadata but it could be optimised to just have one:
It is possible to change the metadata by performing an object copy (see How to update metadata using Amazon S3 SDK):
Whether this is philosophically an "update" is up to you to decide.
You can't:
http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
In my case, I care about the object versions, and copying creates a new version. I decided to create a parallel, "hidden" object with the mutable metadata. For example, if I have
/foo/bar/baz
, then I would create/foo/bar/.baz
.PHP Example
I understand this question was not PHP specific, but it may help someone as it is a top result on Google.
This will overwrite the existing object.