Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

python - Receiving a dictionary of files in FastAPI

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.)

question from:https://stackoverflow.com/questions/65883452/receiving-a-dictionary-of-files-in-fastapi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...