If you want to get a file from an S3 Bucket and then put it in a Python string, try the examples below.
boto3, the AWS SDK for Python, offers two distinct methods for accessing files or objects in Amazon S3: client
method and the resource
method.
Option 1 uses the boto3.client('s3')
method, while options 2 and 3 use the boto3.resource('s3')
method.
All 3 options do the exact same thing so get the one that you feel comfortable with or the one that will fit your use case.
- Option 1: boto3 S3 Client
- Option 2: boto3 S3 Resource
- Option 3: boto3 S3 Resource alternative
- boto3 resource and boto3 client
- The .get_object() method
- The response[‘Body’] object and .decode() method
- Reading and Processing S3 Text Files Line by Line
- Reading S3 files via AWS Lambda Python Code