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: octet/stream => application/octet-stream (#15329)

Willaef43910b1a0
diff --git a/api/core/tools/docs/en_US/advanced_scale_out.md b/api/core/tools/docs/en_US/advanced_scale_out.md
index 644ad291292..d6cab690ccc 100644
--- a/api/core/tools/docs/en_US/advanced_scale_out.md
+++ b/api/core/tools/docs/en_US/advanced_scale_out.md
@@ -55,7 +55,7 @@ If you need to return a text message, you can use the following interface.
If you need to return the raw data of a file, such as images, audio, video, PPT, Word, Excel, etc., you can use the following interface.
- `blob` The raw data of the file, of bytes type
-- `meta` The metadata of the file, if you know the type of the file, it is best to pass a `mime_type`, otherwise Dify will use `octet/stream` as the default type
+- `meta` The metadata of the file, if you know the type of the file, it is best to pass a `mime_type`, otherwise Dify will use `application/octet-stream` as the default type
```python
def create_blob_message(self, blob: bytes, meta: dict = None, save_as: str = '') -> ToolInvokeMessage:
diff --git a/api/core/tools/docs/ja_JP/advanced_scale_out.md b/api/core/tools/docs/ja_JP/advanced_scale_out.md
index 96f843354f9..10ede6fda6a 100644
--- a/api/core/tools/docs/ja_JP/advanced_scale_out.md
+++ b/api/core/tools/docs/ja_JP/advanced_scale_out.md
@@ -58,7 +58,7 @@ Difyは`テキスト`、`リンク`、`画像`、`ファイルBLOB`、`JSON`な
画像、音声、動画、PPT、Word、Excelなどのファイルの生データを返す必要がある場合は、以下のインターフェースを使用できます。
- `blob` ファイルの生データ(bytes型)
-- `meta` ファイルのメタデータ。ファイルの種類が分かっている場合は、`mime_type`を渡すことをお勧めします。そうでない場合、Difyはデフォルトタイプとして`octet/stream`を使用します。
+- `meta` ファイルのメタデータ。ファイルの種類が分かっている場合は、`mime_type`を渡すことをお勧めします。そうでない場合、Difyはデフォルトタイプとして`application/octet-stream`を使用します。
```python
def create_blob_message(self, blob: bytes, meta: dict = None, save_as: str = '') -> ToolInvokeMessage:
diff --git a/api/core/tools/docs/zh_Hans/advanced_scale_out.md b/api/core/tools/docs/zh_Hans/advanced_scale_out.md
index 0385dfe4e7b..c436a648817 100644
--- a/api/core/tools/docs/zh_Hans/advanced_scale_out.md
+++ b/api/core/tools/docs/zh_Hans/advanced_scale_out.md
@@ -58,7 +58,7 @@ Dify支持`文本` `链接` `图片` `文件BLOB` `JSON` 等多种消息类型
如果你需要返回文件的原始数据,如图片、音频、视频、PPT、Word、Excel等,可以使用以下接口。
- `blob` 文件的原始数据,bytes类型
-- `meta` 文件的元数据,如果你知道该文件的类型,最好传递一个`mime_type`,否则Dify将使用`octet/stream`作为默认类型
+- `meta` 文件的元数据,如果你知道该文件的类型,最好传递一个`mime_type`,否则Dify将使用`application/octet-stream`作为默认类型
```python
def create_blob_message(self, blob: bytes, meta: dict = None, save_as: str = '') -> ToolInvokeMessage:
diff --git a/api/core/tools/tool_engine.py b/api/core/tools/tool_engine.py
index 37b4582381e..cf5411112d0 100644
--- a/api/core/tools/tool_engine.py
+++ b/api/core/tools/tool_engine.py
@@ -290,14 +290,16 @@ class ToolEngine:
raise ValueError("missing meta data")
yield ToolInvokeMessageBinary(
- mimetype=response.meta.get("mime_type", "octet/stream"),
+ mimetype=response.meta.get("mime_type", "application/octet-stream"),
url=cast(ToolInvokeMessage.TextMessage, response.message).text,
)
elif response.type == ToolInvokeMessage.MessageType.LINK:
# check if there is a mime type in meta
if response.meta and "mime_type" in response.meta:
yield ToolInvokeMessageBinary(
- mimetype=response.meta.get("mime_type", "octet/stream") if response.meta else "octet/stream",
+ mimetype=response.meta.get("mime_type", "application/octet-stream")
+ if response.meta
+ else "application/octet-stream",
url=cast(ToolInvokeMessage.TextMessage, response.message).text,
)
diff --git a/api/core/tools/tool_file_manager.py b/api/core/tools/tool_file_manager.py
index 967cddac6cf..360dfb9b4cb 100644
--- a/api/core/tools/tool_file_manager.py
+++ b/api/core/tools/tool_file_manager.py
@@ -101,7 +101,7 @@ class ToolFileManager:
except httpx.TimeoutException:
raise ValueError(f"timeout when downloading file from {file_url}")
- mimetype = guess_type(file_url)[0] or "octet/stream"
+ mimetype = guess_type(file_url)[0] or "application/octet-stream"
extension = guess_extension(mimetype) or ".bin"
unique_name = uuid4().hex
filename = f"{unique_name}{extension}"
diff --git a/api/core/tools/utils/message_transformer.py b/api/core/tools/utils/message_transformer.py
index d92aa5ee600..ec0b3a58634 100644
--- a/api/core/tools/utils/message_transformer.py
+++ b/api/core/tools/utils/message_transformer.py
@@ -58,7 +58,7 @@ class ToolFileMessageTransformer:
# get mime type and save blob to storage
meta = message.meta or {}
- mimetype = meta.get("mime_type", "octet/stream")
+ mimetype = meta.get("mime_type", "application/octet-stream")
# if message is str, encode it to bytes
if not isinstance(message.message, ToolInvokeMessage.BlobMessage):