Код: Выделить всё
@app.post("/create_file")
async def create_file(file: UploadFile = File(...)):
file2store = await file.read()
# some code to store the BytesIO(file2store) to the other database
Код: Выделить всё
f = open(".../file.txt", 'rb')
files = {"file": (f.name, f, "multipart/form-data")}
requests.post(url="SERVER_URL/create_file", files=files)
Я также попробовал bytes, а не UploadFile, но я получаю те же результаты. Что-то не так с моим кодом или я неправильно использую FastAPI для загрузки файла?
Подробнее здесь: https://stackoverflow.com/questions/630 ... ng-fastapi
Мобильная версия