8
n8n 中文网amn8n.com

更改二进制MIME类型-扩展名

中级

这是一个AI领域的自动化工作流,包含 6 个节点。主要使用 Set, Code, ExtractFromFile, ExecuteWorkflowTrigger 等节点,结合人工智能技术实现智能自动化。 更改二进制MIME类型/扩展名

前置要求
  • AI 服务 API Key(如 OpenAI、Anthropic 等)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "e409ea34548a2afe2dffba31130cd1cf2e98ebe2afaeed2a63caf2a0582d1da0"
  },
  "nodes": [
    {
      "id": "491b237e-9d42-4017-bc80-9301367e4469",
      "name": "从文件提取",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        220,
        -80
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery",
        "binaryPropertyName": "={{ Object.keys($binary).first() }}"
      },
      "typeVersion": 1
    },
    {
      "id": "2a7ea7bd-b009-4219-a5da-5d62976185a5",
      "name": "设置输出文件名",
      "type": "n8n-nodes-base.set",
      "position": [
        -160,
        -80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "db6b30b5-a420-430b-87ae-a4887bfe9628",
              "name": "binary_key",
              "type": "string",
              "value": "={{ Object.keys($binary).first() }}"
            },
            {
              "id": "8e1643f7-e794-43b2-a5ac-80b6b621b547",
              "name": "output_file_name",
              "type": "string",
              "value": "SET YOUR OUTPUT FILE NAME AND EXTENSION !! (ex: .mp3 or .png)"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "b9e1072b-c9c2-4d5b-a13a-4eed7a920203",
      "name": "更改二进制数据类型",
      "type": "n8n-nodes-base.code",
      "position": [
        440,
        -80
      ],
      "parameters": {
        "jsCode": "const myBuffer = Buffer.from($json.data, 'base64');\n\n$input.item.binary = {\n  [$('SET OUTPUT FILE NAME').last().json.binary_key]: await this.helpers.prepareBinaryData(myBuffer, $('SET OUTPUT FILE NAME').last().json.output_file_name)\n};\n\nreturn $input.item;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "e5fc3b22-3f86-4cef-b0c7-d2f8b7261784",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -420
      ],
      "parameters": {
        "color": 3,
        "width": 420,
        "height": 500,
        "content": "### ⚙️ 在此处配置 ⚙️"
      },
      "typeVersion": 1
    },
    {
      "id": "41ac8c2b-6530-46bc-9153-8b3c312076f9",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        140,
        -340
      ],
      "parameters": {
        "color": 7,
        "width": 480,
        "height": 420,
        "content": "### ⚙️ 核心逻辑(无需编辑)"
      },
      "typeVersion": 1
    },
    {
      "id": "d7de41a8-eb35-4b84-862f-9a2deb438d93",
      "name": "更改二进制 MIME 类型/扩展名",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -520,
        -80
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    }
  ],
  "pinData": {},
  "connections": {
    "Extract from File": {
      "main": [
        [
          {
            "node": "Change Binary Data Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SET OUTPUT FILE NAME": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Change Binary MimeType/Extension": {
      "main": [
        [
          {
            "node": "SET OUTPUT FILE NAME",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 人工智能

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量6
分类1
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Lucas Peyrin

Lucas Peyrin

@lucaspeyrin

Innovative builder with a passion for crafting automation solutions that solve real-world challenges. From streamlining workflows to driving efficiency, my work empowers teams and individuals to achieve more with less effort. Experienced in developing scalable tools and strategies that deliver results with n8n, supabase and cline.

外部链接
在 n8n.io 查看

分享此工作流