So i want to create a matplotlib pie chart using some data then save it to BytesIO and send to my S3 bucket to store and use this picture later. No errors appear during the operation, its successfully uploaded on my S3 with correct name but the file's size is 0 and it is completely empty, though buf is not empty if i check it via print() before uplaod.
async def generate_pie_chart():
slices = [33,33,33]
fig = Figure()
pie = fig.subplots()
pie.pie(slices)
buf = BytesIO()
fig.savefig(buf, format="png")
S3_CLIENT.upload_fileobj(buf, S3_BUCKET, 'piee')