Updating An Object's Metadata On S3
One complaint I've seen a lot around the internet is that you can't update the metadata of an object on S3.
While this is partly true, there's a way to do it.
What you do is using the copy method, an HTTP PUT with a x-amz-copy-source header, you set the metadata with the x-amz-metadata-directive and copy to the same object!
Using simples3, you can do this with:
bucket.copy(bucket.name + "/obj.txt", "obj.txt", metadata={"new": "metadata"},
acl="public-read", mimetype="text/plain")
One thing to note here is that S3 doesn't copy anything but the object data! That includes content type, ACL, and previous metadata.
You might like to make an info request first, to get these values so you can merge with new values. But note that it won't be atomic!
Comments
