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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix:Improve MIME type detection for remote URL uploads using python-magic (#12693)
yjc980121aad7e4dd1c0c
diff --git a/api/controllers/common/helpers.py b/api/controllers/common/helpers.pyindex 2bae2037126..fa42ce4c431 100644--- a/api/controllers/common/helpers.py+++ b/api/controllers/common/helpers.py@@ -7,6 +7,7 @@ from typing import Anyfrom uuid import uuid4import httpx+import magicfrom pydantic import BaseModelfrom configs import dify_config@@ -47,6 +48,13 @@ def guess_file_info_from_response(response: httpx.Response):# If guessing fails, use Content-Type from response headersmimetype = response.headers.get("Content-Type", "application/octet-stream")+ # Use python-magic to guess MIME type if still unknown or generic+ if mimetype == "application/octet-stream":+ try:+ mimetype = magic.from_buffer(response.content[:1024], mime=True)+ except magic.MagicException:+ pass+extension = os.path.splitext(filename)[1]# Ensure filename has an extension