Add POST /documents/upload/batch endpoint for issue 435#528
Open
parthpatidar03 wants to merge 1 commit into
Open
Add POST /documents/upload/batch endpoint for issue 435#528parthpatidar03 wants to merge 1 commit into
parthpatidar03 wants to merge 1 commit into
Conversation
Author
|
@param20h plz check the pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #435
Adds a new
POST /documents/upload/batchendpoint that allows users to upload multiple PDF/DOCX/TXT/MD files simultaneously. Each file is validated, saved, and enqueued as an independent Celery task for parallel RAG ingestion — without blocking the API response.Changes
backend/app/routes/documents.pyPOST /documents/upload/batchendpointfiles: List[UploadFile]viamultipart/form-datavalidate_upload()pipeline (extension → size → MIME → deep parse)process_document.delay()Celery task per fileBackgroundTasksif Celery is unavailable (consistent with single upload)202 Acceptedimmediately with per-file resultsbackend/app/schemas.pyBatchUploadResultschema — per-file outcome withfilename,success, optionaldocument, optionalerrorBatchUploadResponseschema — wraps results list withtotal,succeeded,failedcountersbackend/tests/test_batch_upload.py401422400202,succeeded: 1202,succeeded: 1,failed: 1task_idprefixedlocal_API Reference
Request
Response
202 Accepted{ "total": 2, "succeeded": 2, "failed": 0, "results": [ { "filename": "file1.pdf", "success": true, "document": { "id": "abc123", "original_name": "file1.pdf", "status": "pending", "task_id": "celery-task-uuid", ... }, "error": null }, { "filename": "file2.pdf", "success": true, "document": { ... }, "error": null } ] }Error cases
401filesfield missing422400failed, rest continueTesting
cd backend pytest tests/test_batch_upload.py -v