1

I create a basic upload example as below. It works fine if the file size is less than 1MB, but got a 400 bad request, "detail": "There was an error parsing the body" once the file size is larger than 1MB. I have installed the python-multipart package.

from typing import List
import uvicorn
from fastapi import FastAPI, UploadFile, File

app = FastAPI(debug=True)


@app.post("/uploadfiles/")
async def create_upload_files(file: UploadFile = File(...)):
    return {"filenames": file.filename}

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)
znz1990
  • 29
  • 1
  • 4
  • probably duplicate of https://stackoverflow.com/questions/67712596/fastapi-throws-400-bad-request-when-i-upload-a-large-file – kosciej16 Dec 13 '21 at 16:06
  • Thanks, it works using https://stackoverflow.com/questions/67712596/fastapi-throws-400-bad-request-when-i-upload-a-large-file's solution! – znz1990 Dec 14 '21 at 00:55

1 Answers1

0

the problem is the version of anyio python package. Consider using versions >= 3.4.0.

znz1990
  • 29
  • 1
  • 4