from fastapi import FastAPI, File, UploadFile from pathlib import Path app = FastAPI() #curl 'http://127.0.0.1:8000/pushUpdate/dev/0.1/linux -H 'accept: application/json' -H 'Content-Type: multipart/form-data' -F 'file=@updatefile.yml' @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}