I would like to upload files (mainly pdf and images, max 16MB) with FastAPI and save it directly in a MongoDB collection in a binary format (bson).
I know how to upload a file with FastAPI and save it in the file system. I know how to load a file from the file system and save it into a MongoDB collection. But my goal is to save the uploaded files directly into MongoDB, without passing through the file system, and the problem is how to code/decode the FastAPI UploadFile object into a MongoDB BinData (bson) format.
Anybody knows how to do it, showing with an example code?