본문으로 건너뛰기
Skillpedia
자동화23k · #10126

n8n-binary-and-data

하는 일

n8n이 파일 내용을 일반 데이터와 따로 저장하는 방식을 설명하고, 파일을 읽고, 전달하고, 올바르게 보내는 방법을 알려 줍니다. 첨부 파일이나 업로드를 다루는 n8n 자동화를 만드는 분들을 위한 스킬입니다.

사용하는 경우

  • ✓n8n 워크플로가 파일을 내려받았는데 다음 단계에서 그 내용을 찾지 못할 때.
  • ✓AI 에이전트가 PDF를 읽거나 이미지를 보게 하고 싶을 때.
  • ✓Merge 단계에서 파일 첨부가 사라지는 것 같을 때.

스킬 링크

https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/czlonkowski/n8n-mcp/blob/main/data/skills/n8n-binary-and-data/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 n8n 워크플로가 Merge 단계 뒤에 PDF 첨부 파일을 잃어버립니다. 고쳐 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 각 워크플로 항목에서 파일 데이터가 어디에 있는지 설명하고, 파일을 읽고, 보관하고, 보내는 방법을 보여 줍니다. 채팅이나 AI 도구가 파일을 필요로 하면 링크로 전달하는 방법도 포함합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

n8n Binary and Data

Every n8n item carries two independent slots: $json for structured data and $binary for file bytes. They travel side by side through the workflow. File contents — the actual PDF, image, or zip — live in $binary, never in $json. Get that split wrong and you read an empty field, lose a file mid-flow, or hand an AI agent a tool input it can't use.

This skill covers where binary lives, how to read and write it, how to keep it from being silently stripped, the hard wall between binary and the AI-agent tool boundary, and why chat surfaces need a URL instead of raw bytes.


The three rules that prevent 90% of binary bugs

  1. File contents are in $binary, not $json. After an HTTP download, a "Read Files", or an email-attachment trigger, the bytes sit in $binary.<key>. $json holds metadata at most. Reading $json.data for file contents gives you nothing.

  2. Binary cannot cross the AI-agent tool boundary — in either direction. Tool arguments and tool return values are JSON only. An uploaded image can't be passed into a tool as a file, and a tool can't return raw bytes. Pre-stage to storage and pass a key or URL through JSON instead. See AGENT_TOOL_BINARY.md.

  3. Chat surfaces render images by URL, not by $binary. Slack, Discord, Teams, Telegram, embedded webhook chat — none of them read the binary slot. The image has to live somewhere a URL can fetch it. See CDN_REQUIREMENT.md.


The two slots

Each item is shaped like this:

{
  "json": { "customerId": 42, "status": "sent" },
  "binary": {
    "invoice": {
      "data": "<base64-encoded bytes>",
      "mimeType": "application/pdf",
      "fileName": "invoice-42.pdf",
      "fileExtension": "pdf"
    }
  }
}

The key inside binary (invoice here) is the binary property name. Most file-handling nodes have a binaryPropertyName parameter that points at it — the producer names the slot, the consumer references it by that name. The default key across most nodes is data, so when nothing tells you otherwise, assume $binary.data.

$json and $binary are separate namespaces. An expression like {{ $binary.invoice.fileName }} reads file metadata; {{ $json.customerId }} reads data. They never mix.

This split also explains a webhook gotcha: a Webhook trigger receiving multipart/form-data puts the uploaded file in $binary and the accompanying form fields in $json.body — so an uploaded file is not somewhere under $json at all. (The $json.body nesting for webhooks is n8n-expression-syntax territory.)

See BINARY_BASICS.md for the full slot anatomy, mime types, and size limits.


Producing binary

You rarely build a $binary slot by hand — nodes populate it for you:

Source How binary appears
HTTP Request with responseFormat: "file" Response body lands in $binary.data (or the name you set)
Read/Write Files from Disk File contents read into $binary
Storage downloads (S3, Google Drive, Dropbox, etc.) Downloaded file in $binary.<key>
Email triggers with attachments Each attachment arrives in $binary
Provider AI media nodes (image/audio gen) Set options.binaryPropertyOutput so the bytes land where the next node looks

For an HTTP download, the one field that matters is responseFormat. Confirm it with get_node on nodes-base.httpRequest — leaving it as the default JSON/string format is the classic reason a downloaded file ends up as garbled text in $json instead of clean bytes in $binary.


Reading and writing binary in a Code node

Most workflows never need to crack open the bytes — they just pass binary through to a consumer (email attachment, file upload, Slack file). When you do need the raw bytes, do it in a Code node.

Read with getBinaryDataBuffer — do not try to base64-decode $binary.<key>.data by hand:

// Code node, "Run Once for Each Item"
const buffer = await this.helpers.getBinaryDataBuffer(0, 'data'); // (itemIndex, propertyName)
const text = buffer.toString('utf-8');
const length = buffer.length;

return [{
  json: { ...$json, length },
  binary: $input.item.binary,   // pass the binary through, or it's gone
}];

Write by building the slot yourself — base64 the bytes plus a mime type and file name:

const text = 'Hello, world!';
return [{
  json: { ok: true },
  binary: {
    report: {
      data: Buffer.from(text).toString('base64'),
    
자주 묻는 질문

파일 내용이 왜 비어 있나요?

파일 내용은 일반 데이터 필드가 아니라 각 항목의 binary 부분에 보관됩니다. 그래서 일반 필드만 확인하면 아무것도 보이지 않습니다.

AI 도구가 파일을 직접 받을 수 있나요?

아니요. 도구의 입력과 출력은 일반 데이터만 가능하므로, 파일은 저장한 뒤 링크나 키로 전달해야 합니다.

채팅 앱은 이미지를 어떻게 보여 주나요?

Slack이나 Telegram 같은 채팅 도구는 원본 파일 데이터가 아니라 이미지 링크가 필요합니다.

상세 정보

작성자의 원본 설명

Handle files and binary data in n8n correctly. Use when working with files, images, PDFs, attachments, uploads or downloads, base64, vision/multimodal input, or when an AI agent needs a file as tool input or output — and whenever the user mentions $binary, binaryPropertyName, "read the PDF", "attach the file", "send the image", Merge losing binary, or a CDN for chat images. Covers the $binary vs $json split, reading/writing binary, keeping binary alive across transforms with Merge, the agent-tool binary boundary, and the CDN/URL requirement for chat surfaces.

repo: czlonkowski/n8n-mcp

인기도

GitHub 스타
23k
순위
#10126
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬