diff --git a/api/apps/document_app.py b/api/apps/document_app.py index fa12af9eb..7d97bfe25 100644 --- a/api/apps/document_app.py +++ b/api/apps/document_app.py @@ -520,12 +520,12 @@ async def get(doc_id): @manager.route("/download/", methods=["GET"]) # noqa: F821 @login_required -def download_attachment(attachment_id): +async def download_attachment(attachment_id): try: ext = request.args.get("ext", "markdown") data = settings.STORAGE_IMPL.get(current_user.id, attachment_id) # data = settings.STORAGE_IMPL.get("eb500d50bb0411f0907561d2782adda5", attachment_id) - response = make_response(data) + response = await make_response(data) response.headers.set("Content-Type", CONTENT_TYPE_MAP.get(ext, f"application/{ext}")) return response diff --git a/api/apps/sdk/doc.py b/api/apps/sdk/doc.py index ad0882eee..3a82eaa54 100644 --- a/api/apps/sdk/doc.py +++ b/api/apps/sdk/doc.py @@ -361,7 +361,7 @@ async def update_doc(tenant_id, dataset_id, document_id): @manager.route("/datasets//documents/", methods=["GET"]) # noqa: F821 @token_required -def download(tenant_id, dataset_id, document_id): +async def download(tenant_id, dataset_id, document_id): """ Download a document from a dataset. --- @@ -411,7 +411,7 @@ def download(tenant_id, dataset_id, document_id): return construct_json_result(message="This file is empty.", code=RetCode.DATA_ERROR) file = BytesIO(file_stream) # Use send_file with a proper filename and MIME type - return send_file( + return await send_file( file, as_attachment=True, download_name=doc[0].name,