From 1611bc7f7574ad4a47a960735fdd824741424391 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 <80892890+shaohuzhang1@users.noreply.github.com> Date: Wed, 9 Jul 2025 22:32:40 +0800 Subject: [PATCH] fix: The original document download file name is incorrect (#3542) --- apps/oss/serializers/file.py | 4 +++- .../ai-chat/component/knowledge-source-component/index.vue | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/oss/serializers/file.py b/apps/oss/serializers/file.py index ad083b0a7..6644ccbf7 100644 --- a/apps/oss/serializers/file.py +++ b/apps/oss/serializers/file.py @@ -1,4 +1,5 @@ # coding=utf-8 +import urllib import uuid_utils.compat as uuid from django.db.models import QuerySet @@ -94,9 +95,10 @@ class FileSerializer(serializers.Serializer): raise NotFound404(404, _('File not found')) file_type = file.file_name.split(".")[-1].lower() content_type = mime_types.get(file_type, 'application/octet-stream') + encoded_filename = urllib.parse.quote(file.file_name) headers = { 'Content-Type': content_type, - 'Content-Disposition': f'{"inline" if file_type == "pdf" else "attachment"}; filename="{file.file_name}"' + 'Content-Disposition': f'{"inline" if file_type == "pdf" else "attachment"}; filename={encoded_filename}' } return HttpResponse( file.get_bytes(), diff --git a/ui/src/components/ai-chat/component/knowledge-source-component/index.vue b/ui/src/components/ai-chat/component/knowledge-source-component/index.vue index 00e268770..b454f9cd9 100644 --- a/ui/src/components/ai-chat/component/knowledge-source-component/index.vue +++ b/ui/src/components/ai-chat/component/knowledge-source-component/index.vue @@ -27,7 +27,7 @@