Back
I'm aware that with Boto 2 it's possible to open an S3 object as a string with:
get_contents_as_string() http://boto.readthedocs.org/en/latest/ref/file.html?highlight=contents%20string#boto.file.key.Key.get_contents_as_string
Is there an equivalent function in boto3?
read() will return bytes, so for Python 3 make sure to use decode() if you want a string to be returned.
import boto3s3 = boto3.resource('s3')obj = s3.Object(bucket, key)obj.get()['Body'].read().decode('utf-8')
import boto3
s3 = boto3.resource('s3')
obj = s3.Object(bucket, key)
obj.get()['Body'].read().decode('utf-8')
Learn how we helped 50,000+ professionals like you !
31k questions
32.8k answers
501 comments
693 users