Receiving a dictionary of files in FastAPI

Viewed 342

The documentation of FastAPI gives a way of receiving multiple files:

@app.post("/uploadfiles/")
async def create_upload_files(files: List[UploadFile] = File(...)):
    ...

However, it's hard to keep track of the list's order in my application, since the number and content of files can change. I would like to identify these files with keys, with something like a Dict:

@app.post("/uploadfiles/")
async def create_upload_files(files: Dict[str, UploadFile] = File(...)):
    ...

Would that work? If not, how could I do it?

(I want to send binary data and keep it as light as possible, so json.dumps or similar serialization functions are not acceptable.)

0 Answers
Related