Spaces:
Sleeping
Sleeping
feat: 创建存储目录
Browse files
api.py
CHANGED
@@ -59,7 +59,9 @@ def read_root():
|
|
59 |
|
60 |
@router.post("/upload/{userId}/{modelId}/{filename}")
|
61 |
async def upload_file(userId: str, modelId: str, filename: str, file: UploadFile = File(...)):
|
62 |
-
|
|
|
|
|
63 |
# try:
|
64 |
with open(file_location, "wb") as buffer:
|
65 |
buffer.write(await file.read())
|
|
|
59 |
|
60 |
@router.post("/upload/{userId}/{modelId}/{filename}")
|
61 |
async def upload_file(userId: str, modelId: str, filename: str, file: UploadFile = File(...)):
|
62 |
+
file_location_folder = os.path.join(UPLOAD_DIRECTORY,userId)
|
63 |
+
file_location = os.path.join(file_location_folder, filename)
|
64 |
+
os.makedirs(file_location_folder, exist_ok=True)
|
65 |
# try:
|
66 |
with open(file_location, "wb") as buffer:
|
67 |
buffer.write(await file.read())
|