I had a problem reading the / .get() object from S3 due to .get() using Python 2.7 inside AWS Lambda.
I added json as an example to show that it became available for analysis :)
import boto3 import json s3 = boto3.client('s3') obj = s3.get_object(Bucket=bucket, Key=key) j = json.loads(obj['Body'].read())
NOTE (for python 2.7): My object is completely ascii, so I don't need .decode('utf-8')
NOTE (for python 3. 6+): we switched to python 3.6 and found that read() now returns bytes so if you want to extract a string from it, you should use:
j = json.loads(obj['Body'].read().decode('utf-8'))
EvgenyKolyakov Mar 11 '17 at 15:52 2017-03-11 15:52
source share