File size: 698 Bytes
57cab59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import shutil
from typing import Any

from fastapi import HTTPException, UploadFile
from fastapi.responses import JSONResponse
from src.modules.uploadDocument.features.uploadDocument_feature import \
    UploadDocumentFeature


class FileUploadController:

    async def handle_file_upload(self, file: UploadFile) -> Any:
        try:
            print(file)
            result = await UploadDocumentFeature.uploadFile(file)
            message = result.get("message", "No message provided")

            return JSONResponse(
                status_code=200, content={"message": message}
            )

        except Exception as e:
            raise HTTPException(status_code=500, detail=str(e))