0

I am migrating code from boto2 to boto3 and want to the equivalent way to set the body of an object using boto3

I have tried using the .put(Body="123") but it replaces the s3 object and if i had some metadata previously, that metadata is removed (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Object.put )

Boto2:

bucket = s3_connection.get_bucket("bucket_name")
k = bucket.get_key("key")
k.set_contents_from_string("content")

This sets the content and still retains other properties like metadata

I'm looking for a way to do this using boto3

  • https://stackoverflow.com/a/39145592/6941447 Try this – Ninad Gaikwad Aug 10 '19 at 17:03
  • @NinadGaikwad I did try that, but the put_object method seems to be replacing the object and its contents. For example any previous metadata that the object had is no longer present after the put_object method – Nikhil Gumidelli Aug 13 '19 at 15:58

0 Answers0