Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Straightforward way to save the contents of an S3 key to a string in boto3?

So when I issue a get() what I have is a dict and the 'Body' member of the dict is a "StreamingBody' type and per How to save S3 object to a file using boto3, I see how I could read from this stream in chunks, but I'm wondering if there's an easier way to do this, a la boto.

like image 466
TerminalDilettante Avatar asked Sep 11 '15 14:09

TerminalDilettante


1 Answers

Update: I have done

response = s3_client.get_object(Bucket=bn,Key=obj['Key'])
contents = response['Body'].read()

which seems to work.

like image 55
TerminalDilettante Avatar answered Oct 12 '22 01:10

TerminalDilettante