关于dify中http节点下载文件时,文件名不为原始文件名问题解决

我在使用http节点下载文件时,文件名默认为UUID,于是我设置了请求头

复制代码
Content-Disposition: attachment; filename*=UTF-8''{file_name}

但是发现还是没有变化

而且我发现设置的Content-Disposition完全没有起作用,并且返回的结果本身就是原始文件名,但是并没有启用,最后files中的filename返回的还是uuid。

我在github上发现有人有相同的问题,并且已经解决

When retrieving files using the HTTP component, the file name is incorrect, including custom plugins. Including the latest version 1.7.2 · Issue #24074 · langgenius/dify

简单来说就是需要去修改后端代码,如果是docker部署就需要去docker中修改,

修改的文件为 api/core/workflow/nodes/http_request/node.py,190行左右,修改为

python 复制代码
content_disposition_filename = None
if parsed_content_disposition:
    content_disposition_filename = parsed_content_disposition.get_filename()

filename = content_disposition_filename or url.split("?")[0].split("/")[-1] or ""
# ... rest of your logic

tool_file = tool_file_manager.create_file_by_raw(
    user_id=self.user_id,
    tenant_id=self.tenant_id,
    conversation_id=None,
    file_binary=content,
    mimetype=mime_type,
    filename=filename,  # <-- pass the filename here
)

随后就可以输出原始文件名的文件了

相关推荐
A尘埃7 分钟前
电子厂PCB板焊点缺陷检测(卷积神经网络CNN)
人工智能·神经网络·cnn
Tadas-Gao8 分钟前
缸中之脑:大模型架构的智能幻象与演进困局
人工智能·深度学习·机器学习·架构·大模型·llm
中金快讯10 分钟前
新视野混合净值波动有几何?贝莱德基金回撤控制策略是否命中关键?
人工智能
楚兴13 分钟前
MacBook M1 安装 OpenClaw 完整指南
人工智能·后端
23遇见19 分钟前
探索CANN:开源AI计算底座的关键组件与技术思想
人工智能
jl486382124 分钟前
变比测试仪显示屏的“标杆“配置!如何兼顾30000小时寿命与六角矢量图精准显示?
人工智能·经验分享·嵌入式硬件·物联网·人机交互
三水不滴28 分钟前
有 HTTP 了为什么还要有 RPC?
经验分享·笔记·网络协议·计算机网络·http·rpc
2301_8187305634 分钟前
transformer(上)
人工智能·深度学习·transformer
木枷41 分钟前
Online Process Reward Learning for Agentic Reinforcement Learning
人工智能·深度学习·机器学习
m0_563745111 小时前
误差卡尔曼滤波在VINS-mono中的应用
人工智能·机器学习