import boto3 from PIL import Image from io import BytesIO BUCKET_NAME = 'planningo-public' DIR_NAME = 'photio/' s3 = boto3.client('s3', aws_access_key_id='AKIAZK42H2NEXBFJWUTD', aws_secret_access_key='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') def get_image_from_s3(image_id): base_image_data = s3.get_object( Bucket=BUCKET_NAME, Key=f'{DIR_NAME}{image_id}.png')['Body'].read() return Image.open(BytesIO(base_image_data))