"""File-BLOB-Handling, abstrahiert fuer spaetere Object-Storage-Migration. Aktuell: speichert direkt in SQLite-BLOBs (projekt_datei.inhalt). Spaeter (wenn DB > 5 GB): Migration auf Hetzner Object-Storage / S3, ohne dass aufrufende Routes geaendert werden muessen. Limits siehe docs/decisions.md#E-016: - 30 MB pro Datei (App-Logik, kein DB-Constraint) """ from typing import Optional # 30 MB als App-Logik-Limit MAX_DATEI_GROESSE = 30 * 1024 * 1024 def datei_speichern( projekt_id: int, dateiname: str, mime_type: str, inhalt: bytes, art: str, hochgeladen_von: int, ) -> tuple[bool, str]: """Speichert eine Datei zum Projekt. Stub fuer Etappe 1, voll in Etappe 6. Returns: (erfolg, fehlertext_oder_id) """ # Etappe 6: Groessen-Check, INSERT in projekt_datei, return id return (False, "Noch nicht implementiert (Etappe 6)") def datei_laden(datei_id: int) -> Optional[dict]: """Laedt eine Datei (inhalt + meta). Stub fuer Etappe 1, voll in Etappe 6.""" return None def datei_loeschen(datei_id: int, durch_profil_id: int) -> bool: """Loescht eine Datei. Stub fuer Etappe 1, voll in Etappe 6.""" return False def groesse_pruefen(inhalt: bytes) -> tuple[bool, str]: """Universal-Helfer: prueft 30-MB-Limit.""" if len(inhalt) > MAX_DATEI_GROESSE: mb = len(inhalt) / 1024 / 1024 return (False, f"Datei zu gross ({mb:.1f} MB, max. 30 MB)") return (True, "")