FEAT: Integrated Document Engine with WebP optimization, Thumbnail generation and Hybrid (NAS/SSD) storage logic
This commit is contained in:
Binary file not shown.
30
backend/app/api/v1/endpoints/documents.py
Normal file
30
backend/app/api/v1/endpoints/documents.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter, Depends, UploadFile, File, BackgroundTasks, HTTPException
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.session import get_db
|
||||
from app.services.document_service import DocumentService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/upload/{parent_type}/{parent_id}")
|
||||
async def upload_document(
|
||||
parent_type: str,
|
||||
parent_id: str,
|
||||
background_tasks: BackgroundTasks,
|
||||
file: UploadFile = File(...),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
Dokumentum feltöltés, optimalizálás és NAS-ra mentés.
|
||||
parent_type: 'organizations' vagy 'assets'
|
||||
"""
|
||||
if parent_type not in ["organizations", "assets"]:
|
||||
raise HTTPException(status_code=400, detail="Érvénytelen cél-típus!")
|
||||
|
||||
doc = await DocumentService.process_upload(file, parent_type, parent_id, db, background_tasks)
|
||||
|
||||
return {
|
||||
"document_id": doc.id,
|
||||
"thumbnail": doc.thumbnail_path,
|
||||
"original_name": doc.original_name,
|
||||
"status": "processed_and_vaulted"
|
||||
}
|
||||
Reference in New Issue
Block a user