I am trying to send multiple files from UI to fastAPI in formData. But the API is throwing error instantly when the API's is triggered.
async def createNewDirectory(files: Optional[List[UploadFile]] =
File(None), content: list = [], db: Session = Depends(get_db)):
try:
print(content)
for file in files:
try:
contents = file.file.read()
with open(file.filename, 'wb') as f:
f.write(contents)
except Exception:
return {"message": "There was an error uploading the
file(s)"}
finally:
file.file.close()
Below is the error i am getting
INFO: Started server process [70987]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to
quit)
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/site-packages/anyio/streams/memory.py", line 81, in receive
return self.receive_nowait()
File "/site-packages/anyio/streams/memory.py", line 76, in
receive_nowait
raise WouldBlock
I am using lastest FastAPI, Starlette version
fastapi==0.100.0
uvicorn==0.22.0
starlette==0.27.0