fix: file name incorrect when download file (#19183)
This commit is contained in:
@@ -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):
|
||||
|
@@ -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' />
|
||||
|
@@ -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' />
|
||||
|
Reference in New Issue
Block a user