mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-08 08:07:21 +08:00
Consolidateion of document upload API (#14106)
### What problem does this PR solve? Consolidation WEB API & HTTP API for document upload Before consolidation Web API: POST /v1/document/upload Http API - POST /api/v1/datasets/<dataset_id>/documents After consolidation, Restful API -- POST /api/v1/datasets/<dataset_id>/documents ### Type of change - [x] Refactoring
This commit is contained in:
@ -332,7 +332,9 @@ def batch_create_datasets(auth, num):
|
||||
|
||||
# DOCUMENT APP
|
||||
def upload_documents(auth, payload=None, files_path=None, *, filename_override=None):
|
||||
url = f"{HOST_ADDRESS}{DOCUMENT_APP_URL}/upload"
|
||||
# New endpoint: /api/v1/datasets/{kb_id}/documents
|
||||
kb_id = payload.get("kb_id") if payload else None
|
||||
url = f"{HOST_ADDRESS}/api/{VERSION}/datasets/{kb_id}/documents"
|
||||
|
||||
if files_path is None:
|
||||
files_path = []
|
||||
@ -340,9 +342,11 @@ def upload_documents(auth, payload=None, files_path=None, *, filename_override=N
|
||||
fields = []
|
||||
file_objects = []
|
||||
try:
|
||||
# Note: kb_id is now in the URL path, not in the form data
|
||||
if payload:
|
||||
for k, v in payload.items():
|
||||
fields.append((k, str(v)))
|
||||
if k != "kb_id": # Skip kb_id as it's in the URL
|
||||
fields.append((k, str(v)))
|
||||
|
||||
for fp in files_path:
|
||||
p = Path(fp)
|
||||
|
||||
Reference in New Issue
Block a user