Код: Выделить всё
Body -> form-data: key=file, value=image.jpeg
Код: Выделить всё
127.0.0.1:54294 - "POST /uploadfile/ HTTP/1.1" 422 Unprocessable Entity
Код: Выделить всё
@app.post("/uploadfile/")
async def create_upload_file(file: UploadFile = File(...)):
img = await file.read()
if file.content_type not in ['image/jpeg', 'image/png']:
raise HTTPException(status_code=406, detail="Please upload only .jpeg files")
async with aiofiles.open(f"{file.filename}", "wb") as f:
await f.write(img)
return {"filename": file.filename}

Подробнее здесь: https://stackoverflow.com/questions/627 ... ng-postman