from fastapi import FastAPI, File, UploadFile from pathlib import Path app = FastAPI() @app.post("/pushUpdate/{branch}/{version}/{os}") async def push_update(file: UploadFile, branch: str,version: str,os: str): nfile = Path(f'{branch}/{version}/{os}/{file.filename}') nfile.parent.mkdir(parents=True, exist_ok=True) print(f'{branch}/{version}/{os}/{file.filename}') with open(f'{branch}/{version}/{os}/{file.filename}',"w") as f : content = await file.read() f.write(content.decode()) f.close() return {"filename": file.filename} @app.post("/uploadfile/") async def create_upload_file(file: UploadFile): with open(file.filename,"w") as f : content = await file.read() f.write(content.decode()) f.close() return {"filename": file.filename}