Spaces:
Sleeping
Sleeping
File size: 474 Bytes
5ae2a0a |
1 2 3 4 5 6 7 8 |
@app.post("/file/upload")
async def upload_file(username: str, uploaded_file: UploadFile = File(...)):
path_to_save_file = Path.home() / username / "saved_files"
path_to_save_file.mkdir(parents=True, exist_ok=True)
file_location = f"{path_to_save_file}/{uploaded_file.filename}"
with open(file_location, "wb+") as file_object:
file_object.write(uploaded_file.file.read())
return {"INFO": f"File '{uploaded_file.filename}' saved to your profile."} |