import boto3
def read_s3_file(bucket_name, file_name):
s3 = boto3.client('s3')
try:
response = s3.get_object(Bucket=bucket_name, Key=file_name)
return response['Body'].read().decode('utf-8')
except Exception as e:
print(f"Error reading file from S3: {e}")
return None
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter