Skip to content

Commit 759fc9f

Browse files
committed
fix: The original document download file name is incorrect
1 parent 7c47f4d commit 759fc9f

File tree

2 files changed

+4
-2
lines changed
  • apps/oss/serializers
  • ui/src/components/ai-chat/component/knowledge-source-component

2 files changed

+4
-2
lines changed

apps/oss/serializers/file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# coding=utf-8
2+
import urllib
23

34
import uuid_utils.compat as uuid
45
from django.db.models import QuerySet
@@ -94,9 +95,10 @@ def get(self, with_valid=True):
9495
raise NotFound404(404, _('File not found'))
9596
file_type = file.file_name.split(".")[-1].lower()
9697
content_type = mime_types.get(file_type, 'application/octet-stream')
98+
encoded_filename = urllib.parse.quote(file.file_name)
9799
headers = {
98100
'Content-Type': content_type,
99-
'Content-Disposition': f'{"inline" if file_type == "pdf" else "attachment"}; filename="{file.file_name}"'
101+
'Content-Disposition': f'{"inline" if file_type == "pdf" else "attachment"}; filename={encoded_filename}'
100102
}
101103
return HttpResponse(
102104
file.get_bytes(),

ui/src/components/ai-chat/component/knowledge-source-component/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</div>
2828
<div class="ml-8" v-else>
2929
<a
30-
:href="getFileUrl(item?.meta?.source_file_id)"
30+
:href="getFileUrl(item?.meta?.source_file_id || item?.source_url)"
3131
target="_blank"
3232
class="ellipsis-1"
3333
:title="item?.document_name?.trim()"

0 commit comments

Comments
 (0)