Add CP→CA→PI platform foundation on MapMil monorepo.
Unify parsing workers, analytics API with PostgreSQL, map UI, and PI distribution into centers/ with Docker Compose. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
UPLOAD_DIR = Path(os.getenv("UPLOAD_DIR", "/data/uploads"))
|
||||
|
||||
ALLOWED_CONTENT_TYPES = {
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/gif",
|
||||
"image/webp",
|
||||
"video/mp4",
|
||||
"video/webm",
|
||||
}
|
||||
|
||||
MAX_FILE_SIZE = 20 * 1024 * 1024
|
||||
|
||||
|
||||
def ensure_upload_dir() -> None:
|
||||
UPLOAD_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def is_allowed_content_type(content_type: str) -> bool:
|
||||
return content_type in ALLOWED_CONTENT_TYPES
|
||||
|
||||
|
||||
def build_stored_name(original_name: str) -> str:
|
||||
suffix = Path(original_name).suffix.lower()
|
||||
return f"{uuid.uuid4().hex}{suffix}"
|
||||
|
||||
|
||||
def media_file_path(stored_name: str) -> Path:
|
||||
return UPLOAD_DIR / stored_name
|
||||
|
||||
|
||||
def remove_media_file(stored_name: str) -> None:
|
||||
path = media_file_path(stored_name)
|
||||
if path.exists():
|
||||
path.unlink()
|
||||
Reference in New Issue
Block a user