first commit

This commit is contained in:
2026-03-11 16:28:04 +08:00
commit c0f9ddabbf
101 changed files with 11601 additions and 0 deletions

View File

View File

@@ -0,0 +1,18 @@
import uuid
from pathlib import Path
from app.core.config import settings
def save_upload(data: bytes, case_id: str, filename: str) -> tuple[str, str]:
"""Save uploaded file and return (file_path, thumb_path) relative to UPLOAD_DIR."""
case_dir = settings.upload_path / case_id
case_dir.mkdir(parents=True, exist_ok=True)
ext = Path(filename).suffix or ".png"
unique_name = f"{uuid.uuid4().hex}{ext}"
file_path = case_dir / unique_name
file_path.write_bytes(data)
relative = f"{case_id}/{unique_name}"
return relative, relative

View File

@@ -0,0 +1,5 @@
import hashlib
def sha256_file(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()