@@ -0,0 +1,1210 @@
+from io import BytesIO%0Aimport json%0Aimport os%0Aimport requests%0Aimport urllib%0Aimport uuid%0A%0A# pillow%0Afrom PIL import Image%0A# boto3 for AWS%0Aimport boto3%0A%0A%0Adef upload_image(url, bucket='gx42-image-source'):%0A    %22%22%22 Save image to S3 bucket for later retrieval%0A%0A    Args:%0A        url: url of image to store%0A        bucket: str S3 bucket to save key%0A%0A    Returns:%0A        success: boolean indicating if upload was successful%0A        full_key_name: uuid  to store in imageURL%0A            eg. 64C27228-0004-4C60-8B7E-95702956700F%0A%0A    Security Defaults to ~/.aws/credential%0A    %22%22%22%0A    imguid = str(uuid.uuid4()).upper()%0A    try:%0A        s3 = boto3.resource('s3')%0A        resp = requests.get(url)%0A        dat = urllib.request.urlopen(resp.url)%0A        img = Image.open(dat)%0A        out_im2 = BytesIO()%0A        img.save(out_im2, 'JPEG', optimize=True, progressive=True)%0A        out_im2.seek(0)%0A        full_key_name = imguid%0A        s3.Bucket(bucket).put_object(%0A            Key=full_key_name,%0A            Body=out_im2,%0A            ACL='public-read',%0A            ContentType='image/jpg',%0A        )%0A        return True, full_key_name%0A    except Exception as e:%0A        print('upload_image ERROR', e)%0A        return False, e

Add code to upload images to S3