fix: add document download endpoint and refactor existing download function (#14927)

### What problem does this PR solve?

add document download endpoint and refactor existing download function

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
buua436
2026-05-15 09:36:58 +08:00
committed by GitHub
parent 5a5bbee948
commit 58819f5d3e
2 changed files with 58 additions and 5 deletions

View File

@@ -1881,8 +1881,6 @@ async def download_attachment(tenant_id=None, doc_id=None, attachment_id=None):
# Keep backward compatibility with older callers and unit tests that still
# pass `attachment_id` instead of the route parameter name.
doc_id = doc_id or attachment_id
if not DocumentService.accessible(doc_id, current_user.id):
return get_data_error_result(message="Document not found!")
ext = request.args.get("ext", "markdown")
data = await thread_pool_exec(settings.STORAGE_IMPL.get, tenant_id, doc_id)
response = await make_response(data)