File size: 413 Bytes
906e061
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import boto3
import io

def s3_open(bucket_name, key):
    # Create a session using your AWS credentials
    session = boto3.Session()
    # Create an S3 client
    s3 = session.client('s3')

    # Download the file object
    response = s3.get_object(Bucket=bucket_name, Key=key)
    file_content = response['Body'].read()

    # Return a BytesIO object to mimic a file object
    return io.BytesIO(file_content)