phase4: entity_attachments table + DMS unified storage + attachment service rewritten + download via DMS

This commit is contained in:
Agent Zero
2026-07-29 17:52:55 +02:00
parent 481125e29e
commit 8322adb73f
5 changed files with 285 additions and 79 deletions
+8 -3
View File
@@ -93,12 +93,17 @@ async def download_attachment(
if data is None:
raise HTTPException(404, detail={"detail": "Attachment not found", "code": "not_found"})
file_path = data["file_path"]
# Use storage backend instead of os.path.isfile (P1.1 fix)
# Get storage path from DMS file via new unified service
storage_path = await attachment_service.get_attachment_download_path(
db, tenant_id, aid, user_id=user_id, is_system_admin=is_admin
)
if storage_path is None:
raise HTTPException(404, detail={"detail": "File not found in DMS", "code": "file_missing"})
from app.core.storage import get_storage_backend
storage = get_storage_backend()
try:
file_bytes = await storage.load(file_path)
file_bytes = await storage.load(storage_path)
except Exception:
raise HTTPException(404, detail={"detail": "File not found in storage", "code": "file_missing"})