add data source

This commit is contained in:
qixinbo
2026-03-15 20:48:40 +08:00
parent f1db709aae
commit a7f1c77787
10 changed files with 119 additions and 29 deletions
+18
View File
@@ -0,0 +1,18 @@
import os
from pathlib import Path
from typing import Optional
def resolve_upload_file_path(file_url: Optional[str]) -> Path:
if not file_url:
raise ValueError("File URL is empty")
if file_url.startswith("local://"):
raw_name = file_url.replace("local://", "", 1)
safe_name = os.path.basename(raw_name)
# Assuming we are in backend/app/core, go up to backend/data/uploads
upload_dir = Path(__file__).resolve().parents[2] / "data" / "uploads"
file_path = upload_dir / safe_name
return file_path
# If it's already an absolute path (or relative path not starting with local://)
return Path(file_url)