1

I have objects in s3 (IBM cos), I'm trying to update metadata like custom user metadata for objects in a bucket. I'm using the below snippet to update the metadata.

But when I retrieve the object after this I'm getting empty content.

import boto3 as client

s3 = client.resource('s3')
obj = s3.Bucket('MyBucket').Object('objectKey')
obj.put(Metadata={'name':'newName'})

Is there any other way to do this or Am I doing it wrongly?

Mathivanan
  • 371
  • 2
  • 16

1 Answers1

0

From the code pasted above it looks like you're just missing a closing paren on your put call. The syntax you used above worked when I tested it:

>>> s3 = client.resource('s3')
>>> obj = s3.Bucket('my_bucket').Object('my_key')
>>> obj.put(Metadata={'foo': 'bar'})
{u'ETag': '"d41d8cd98f00b204e9800998ecf8427e"', 'ResponseMetadata': {'HTTPStatusCode': 200, 'RetryAttempts': 0, 'HostId': ...
>>> print obj.metadata
{'foo': 'bar'}
P Gilson
  • 63
  • 2
  • 6