mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-01 08:15:44 +08:00
Fix: add compatibility route for document download under /v1 (#14663)
### What problem does this PR solve? add compatibility route for document download under /v1 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -31,6 +31,7 @@ Deprecated APIs and their replacements:
|
||||
- POST /api/v1/file/* -> POST /api/v1/files*
|
||||
- GET /api/v1/document/get/{doc_id} -> GET /api/v1/documents/{doc_id}/preview
|
||||
- GET /api/v1/document/download/{doc_id} -> GET /api/v1/documents/{doc_id}/download
|
||||
- GET /v1/document/download/{attachment_id} -> GET /api/v1/documents/{attachment_id}/download
|
||||
- POST /api/v1/sessions/related_questions -> POST /api/v1/chat/recommandation
|
||||
- PUT (chunk update) -> PATCH (chunk update)
|
||||
"""
|
||||
@@ -45,6 +46,7 @@ from api.apps.services import file_api_service
|
||||
from api.utils.api_utils import get_data_error_result, get_json_result, add_tenant_id_to_kwargs
|
||||
|
||||
manager = Blueprint("backward_compat", __name__)
|
||||
document_download_manager = Blueprint("backward_compat_document_download", __name__)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
@@ -434,6 +436,23 @@ async def deprecated_document_download(doc_id):
|
||||
)
|
||||
return await document_api.download_attachment(doc_id=doc_id)
|
||||
|
||||
|
||||
@document_download_manager.route("/document/download/<attachment_id>", methods=["GET"])
|
||||
@login_required
|
||||
async def document_download_v1(attachment_id):
|
||||
"""
|
||||
Compatibility alias for document download under /v1.
|
||||
|
||||
Old path: GET /v1/document/download/{attachment_id}
|
||||
New path: GET /api/v1/documents/{attachment_id}/download
|
||||
"""
|
||||
logging.warning(
|
||||
"API endpoint /v1/document/download/%s is deprecated. "
|
||||
"Please use /api/v1/documents/%s/download instead.",
|
||||
attachment_id, attachment_id,
|
||||
)
|
||||
return await document_api.download_attachment(attachment_id=attachment_id)
|
||||
|
||||
# =============================================================================
|
||||
# Agent Chat API
|
||||
# =============================================================================
|
||||
@@ -460,4 +479,5 @@ def register_backward_compat_routes(app_instance):
|
||||
Register all backward compatibility routes with the app.
|
||||
"""
|
||||
app_instance.register_blueprint(manager, url_prefix="/api/v1")
|
||||
app_instance.register_blueprint(document_download_manager, url_prefix="/v1")
|
||||
logging.info("Backward compatibility routes registered successfully.")
|
||||
|
||||
@@ -6882,7 +6882,7 @@ Failure:
|
||||
curl --request GET \
|
||||
--url 'http://{address}/api/v1/documents/{doc_id}/download?ext=pdf' \
|
||||
--header 'Authorization: Bearer <YOUR_API_KEY>' \
|
||||
--output ./downloaded_attachment.pdf
|
||||
--output ./downloaded_attachment.pdf
|
||||
```
|
||||
|
||||
##### Request parameters
|
||||
|
||||
Reference in New Issue
Block a user