Commit ·
9debae5
1
Parent(s): a531fcc
[NOTICKET]: add doctypes endpoint & 10MB file size limit
Browse files
src/api/v1/document.py
CHANGED
|
@@ -24,6 +24,22 @@ class DocumentResponse(BaseModel):
|
|
| 24 |
created_at: str
|
| 25 |
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
@router.get("/documents/{user_id}", response_model=List[DocumentResponse])
|
| 28 |
@log_execution(logger)
|
| 29 |
async def list_documents(
|
|
|
|
| 24 |
created_at: str
|
| 25 |
|
| 26 |
|
| 27 |
+
@router.get("/documents/doctypes")
|
| 28 |
+
@log_execution(logger)
|
| 29 |
+
async def get_document_types():
|
| 30 |
+
"""List supported document types with max file size and status."""
|
| 31 |
+
return {
|
| 32 |
+
"status": "success",
|
| 33 |
+
"data": [
|
| 34 |
+
{"doc_type": "pdf", "max_size": 10, "status": "active", "message": None},
|
| 35 |
+
{"doc_type": "docx", "max_size": 10, "status": "active", "message": None},
|
| 36 |
+
{"doc_type": "txt", "max_size": 10, "status": "active", "message": None},
|
| 37 |
+
{"doc_type": "csv", "max_size": 10, "status": "active", "message": None},
|
| 38 |
+
{"doc_type": "xlsx", "max_size": 10, "status": "active", "message": None},
|
| 39 |
+
]
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
@router.get("/documents/{user_id}", response_model=List[DocumentResponse])
|
| 44 |
@log_execution(logger)
|
| 45 |
async def list_documents(
|
src/pipeline/document_pipeline/document_pipeline.py
CHANGED
|
@@ -21,6 +21,13 @@ class DocumentPipeline:
|
|
| 21 |
content = await file.read()
|
| 22 |
file_type = file.filename.split(".")[-1].lower() if "." in file.filename else "txt"
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
if file_type not in SUPPORTED_FILE_TYPES:
|
| 25 |
raise HTTPException(
|
| 26 |
status_code=400,
|
|
|
|
| 21 |
content = await file.read()
|
| 22 |
file_type = file.filename.split(".")[-1].lower() if "." in file.filename else "txt"
|
| 23 |
|
| 24 |
+
MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024 # 10 MB
|
| 25 |
+
if len(content) > MAX_FILE_SIZE_BYTES:
|
| 26 |
+
raise HTTPException(
|
| 27 |
+
status_code=400,
|
| 28 |
+
detail="File size exceeds maximum allowed size of 10 MB.",
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
if file_type not in SUPPORTED_FILE_TYPES:
|
| 32 |
raise HTTPException(
|
| 33 |
status_code=400,
|