Sfoglia il codice sorgente

fix: octet/stream => application/octet-stream (#15329)

Co-authored-by: crazywoola <427733928@qq.com>
Will 1 mese fa
parent
commit
aef43910b1

+ 1 - 1
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:

+ 1 - 1
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:

+ 1 - 1
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:

+ 4 - 2
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,
                     )
 

+ 1 - 1
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}"

+ 1 - 1
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):