diff --git a/backend/apps/datasource/api/datasource.py b/backend/apps/datasource/api/datasource.py index d4e24b7a..01c704d0 100644 --- a/backend/apps/datasource/api/datasource.py +++ b/backend/apps/datasource/api/datasource.py @@ -534,12 +534,12 @@ async def upload_ds_schema(session: SessionDep, id: int = Path(..., description= @router.post("/parseExcel", response_model=None, summary=f"{PLACEHOLDER_PREFIX}ds_parse_excel") @require_permissions(permission=SqlbotPermission(role=['ws_admin'])) async def parse_excel(file: UploadFile = File(..., description=f"{PLACEHOLDER_PREFIX}ds_excel")): - ALLOWED_EXTENSIONS = {"xlsx", "xls", "csv"} + ALLOWED_EXTENSIONS = {".xlsx", ".xls", ".csv"} if not file.filename.lower().endswith(tuple(ALLOWED_EXTENSIONS)): raise HTTPException(400, "Only support .xlsx/.xls/.csv") os.makedirs(path, exist_ok=True) - filename = f"{file.filename.split('.')[0]}_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}.{file.filename.split('.')[1]}" + filename = f"{file.filename.split('.')[0]}_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}.{file.filename.split('.')[-1]}" save_path = os.path.join(path, filename) with open(save_path, "wb") as f: f.write(await file.read())