From 96ce6024338388ccf1f276dbfa352fb9a165f69d Mon Sep 17 00:00:00 2001 From: Suraj Jha Date: Tue, 19 Aug 2025 23:44:41 +0545 Subject: [PATCH] fix: max file size to 100mb for custom template --- nginx.conf | 2 +- servers/fastapi/api/v1/ppt/endpoints/files.py | 2 +- servers/fastapi/api/v1/ppt/endpoints/pdf_slides.py | 6 ++++++ servers/fastapi/api/v1/ppt/endpoints/pptx_slides.py | 6 ++++++ .../custom-template/components/FileUploadSection.tsx | 2 +- .../custom-template/hooks/useFileUpload.ts | 6 +++--- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/nginx.conf b/nginx.conf index 5796df6b..3abcb5d9 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,7 +8,7 @@ events { } http { - client_max_body_size 20M; + client_max_body_size 100M; server { listen 80; diff --git a/servers/fastapi/api/v1/ppt/endpoints/files.py b/servers/fastapi/api/v1/ppt/endpoints/files.py index b19e31d0..25936e6a 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/files.py +++ b/servers/fastapi/api/v1/ppt/endpoints/files.py @@ -20,7 +20,7 @@ async def upload_files(files: Optional[List[UploadFile]]): temp_dir = TEMP_FILE_SERVICE.create_temp_dir(get_random_uuid()) - validate_files(files, True, True, 50, UPLOAD_ACCEPTED_FILE_TYPES) + validate_files(files, True, True, 100, UPLOAD_ACCEPTED_FILE_TYPES) temp_files: List[str] = [] if files: diff --git a/servers/fastapi/api/v1/ppt/endpoints/pdf_slides.py b/servers/fastapi/api/v1/ppt/endpoints/pdf_slides.py index 1acd3b8d..56df3c28 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/pdf_slides.py +++ b/servers/fastapi/api/v1/ppt/endpoints/pdf_slides.py @@ -46,6 +46,12 @@ async def process_pdf_slides( status_code=400, detail=f"Invalid file type. Expected PDF file, got {pdf_file.content_type}" ) + # Enforce 100MB size limit + if hasattr(pdf_file, "size") and pdf_file.size and pdf_file.size > (100 * 1024 * 1024): + raise HTTPException( + status_code=400, + detail="PDF file exceeded max upload size of 100 MB", + ) # Create temporary directory for processing with tempfile.TemporaryDirectory() as temp_dir: diff --git a/servers/fastapi/api/v1/ppt/endpoints/pptx_slides.py b/servers/fastapi/api/v1/ppt/endpoints/pptx_slides.py index 9b922f3c..473c5dca 100644 --- a/servers/fastapi/api/v1/ppt/endpoints/pptx_slides.py +++ b/servers/fastapi/api/v1/ppt/endpoints/pptx_slides.py @@ -275,6 +275,12 @@ async def process_pptx_slides( status_code=400, detail=f"Invalid file type. Expected PPTX file, got {pptx_file.content_type}" ) + # Enforce 100MB size limit + if hasattr(pptx_file, "size") and pptx_file.size and pptx_file.size > (100 * 1024 * 1024): + raise HTTPException( + status_code=400, + detail="PPTX file exceeded max upload size of 100 MB", + ) # Create temporary directory for processing with tempfile.TemporaryDirectory() as temp_dir: diff --git a/servers/nextjs/app/(presentation-generator)/custom-template/components/FileUploadSection.tsx b/servers/nextjs/app/(presentation-generator)/custom-template/components/FileUploadSection.tsx index 0c164890..0739410e 100644 --- a/servers/nextjs/app/(presentation-generator)/custom-template/components/FileUploadSection.tsx +++ b/servers/nextjs/app/(presentation-generator)/custom-template/components/FileUploadSection.tsx @@ -39,7 +39,7 @@ export const FileUploadSection: React.FC = ({ Upload PDF or PPTX File - Select a PDF or PowerPoint file (.pdf or .pptx) to process. Maximum file size: 50MB + Select a PDF or PowerPoint file (.pdf or .pptx) to process. Maximum file size: 100MB {slides.length > 0 && (
diff --git a/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useFileUpload.ts b/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useFileUpload.ts index db9f4d1f..35ac1341 100644 --- a/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useFileUpload.ts +++ b/servers/nextjs/app/(presentation-generator)/custom-template/hooks/useFileUpload.ts @@ -18,10 +18,10 @@ export const useFileUpload = () => { return; } - // Validate file size (50MB limit) - const maxSize = 50 * 1024 * 1024; // 50MB + // Validate file size (100MB limit) + const maxSize = 100 * 1024 * 1024; // 100MB if (file.size > maxSize) { - toast.error("File size must be less than 50MB"); + toast.error("File size must be less than 100MB"); return; }