In an AWS lambda, I am using boto3 to put a string into an S3 file:
import boto3
s3 = boto3.client('s3')
data = s3.get_object(Bucket=XXX, Key=YYY)
data.put('Body', 'hello')
I am told this:
[ERROR] AttributeError: 'dict' object has no attribute 'put'
The same happens with data.put('hello')
which is the method recommended by the top answers at How to write a file or data to an S3 object using boto3 and with data.put_object
: 'dict' object has no attribute 'put_object'
.
What am I doing wrong?
On the opposite, reading works great (with data.get('Body').read().decode('utf-8')
).