'Upload pil image object in s3 using boto3

I am trying to upload a pil object in S3 using boto3.

FileObj = bucket.Object(s3_file.key)
file_stream = io.BytesIO()
FileObj.download_fileobj(file_stream)
watermarked_image_obj = Image.open(file_stream)
FileObj.upload_fileobj(watermarked_image_obj,  ExtraArgs={'ACL':'public-read'})

But it showing an error like this.

   File "./Desktop/image_watermark/venv/lib/python3.8/site-packages/boto3    
       /s3/inject.py", line 525, in upload_fileobj
   raise ValueError('Fileobj must implement read')
   ValueError: Fileobj must implement read

What should I do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source