I have the following code where trying to convert and UploadFile from a REST call to pillow image. The request is sent via POSTMAN with form-data in body section and a simple png image as input.
from fastapi import File, APIRouter
from PIL import Image
from io import BytesIO
@api.post("/myEndPoint")
def function(
img: UploadFile
)
img_pillow = Image.open(BytesIO(img.file.read()))
However, I get the following error: PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000002A05D4A59A0>.
Any idea how I can do this conversion smoothly?