saving an image to bytes and uploading to boto3 returning content-MD5 mismatch

I had this same problem, and the solution was to seek to the beginning of the saved in-memory file:

out_img = BytesIO()
image.save(out_img, img_type)
out_img.seek(0)  # Without this line it fails
self.bucket.put_object(Bucket=self.bucket_name,
                       Key=key,
                       Body=out_img)

The file may need to be saved and reloaded before you send it off to S3. The file pointer seek also needs to be at 0.

My problem was sending a file after reading out the first few bytes of it. Opening a file cleanly did the trick.