I have this simple python lambda that downloads a JPG image and uploads it to a S3 bucket.
url = 'https://somesite.com/11/frame.jpg?abs_begin=2019-08-29T05:18:26Z'
s3 = boto3.client('s3')
with contextlib.closing(requests.get(url, stream=True, verify=False)) as response:
fp = BytesIO(response.content)
s3.upload_fileobj(fp, bucket_name, 'my-dir/' + 'test_img.jpg')
However, when looking in my bucket it says file size is 162 bytes. When dowloading it from the browser GUI to my local disk macOS prompts: The file "test_img.jpg" could not be opened.
and It may be damaged or use a file format that Preview doesn’t recognise.
Any idea what causes this?