Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: file name incorrect when download file (#19183)

非法操作1ca6dbcdc885
diff --git a/api/core/tools/utils/message_transformer.py b/api/core/tools/utils/message_transformer.py
index 0dbc9ccbcc7..257d96133e5 100644
--- a/api/core/tools/utils/message_transformer.py
+++ b/api/core/tools/utils/message_transformer.py
@@ -60,7 +60,7 @@ class ToolFileMessageTransformer:
mimetype = meta.get("mime_type", "application/octet-stream")
# get filename from meta
- filename = meta.get("file_name", None)
+ filename = meta.get("filename", None)
# if message is str, encode it to bytes
if not isinstance(message.message, ToolInvokeMessage.BlobMessage):
diff --git a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx
index df2e03db2d8..51603480020 100644
--- a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx
+++ b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-image-item.tsx
@@ -32,6 +32,7 @@ const FileImageItem = ({
}: FileImageItemProps) => {
const { id, progress, base64Url, url, name } = file
const [imagePreviewUrl, setImagePreviewUrl] = useState('')
+ const download_url = url ? `${url}&as_attachment=true` : base64Url
return (
<>
@@ -84,7 +85,7 @@ const FileImageItem = ({
className='absolute bottom-0.5 right-0.5 flex h-6 w-6 items-center justify-center rounded-lg bg-components-actionbar-bg shadow-md'
onClick={(e) => {
e.stopPropagation()
- downloadFile(url || base64Url || '', name)
+ downloadFile(download_url || '', name)
}}
>
<RiDownloadLine className='h-4 w-4 text-text-tertiary' />
diff --git a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx
index a0984061608..667bf7cc153 100644
--- a/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx
+++ b/web/app/components/base/file-uploader/file-uploader-in-chat-input/file-item.tsx
@@ -45,6 +45,7 @@ const FileItem = ({
let tmp_preview_url = url || base64Url
if (!tmp_preview_url && file?.originalFile)
tmp_preview_url = URL.createObjectURL(file.originalFile.slice()).toString()
+ const download_url = url ? `${url}&as_attachment=true` : base64Url
return (
<>
@@ -93,13 +94,13 @@ const FileItem = ({
}
</div>
{
- showDownloadAction && tmp_preview_url && (
+ showDownloadAction && download_url && (
<ActionButton
size='m'
className='absolute -right-1 -top-1 hidden group-hover/file-item:flex'
onClick={(e) => {
e.stopPropagation()
- downloadFile(tmp_preview_url || '', name)
+ downloadFile(download_url || '', name)
}}
>
<RiDownloadLine className='h-3.5 w-3.5 text-text-tertiary' />