{
  "id": "nextjs/server-action-formdata-arraybuffer",
  "signature": "Error: Server Actions cannot receive ArrayBuffer or Blob directly from FormData. Use File objects or convert to base64.",
  "signature_zh": "错误：服务端操作无法直接从 FormData 接收 ArrayBuffer 或 Blob。请使用 File 对象或转换为 base64。",
  "regex": "Error: Server Actions cannot receive ArrayBuffer or Blob directly from FormData\\. Use File objects or convert to base64\\.",
  "domain": "nextjs",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A Server Action receives FormData containing ArrayBuffer or Blob entries, which are not directly serializable for server transmission. Next.js Server Actions only support File, string, or number types from FormData.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务端操作接收到的 FormData 包含 ArrayBuffer 或 Blob 条目，这些类型无法直接序列化用于服务端传输。Next.js 服务端操作仅支持来自 FormData 的 File、string 或 number 类型。",
  "versions": [
    {
      "version": "Next.js 14.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Next.js 15.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "ArrayBuffer is binary data; JSON.parse will fail on it unless it is already a JSON string. This approach also does not address the serialization issue for the Server Action.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "FormData serialization does not support ArrayBuffer; it will be converted to a string '[object ArrayBuffer]' or cause a TypeError during submission.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Next.js Server Actions handle FormData parsing internally before middleware runs. You cannot intercept the request body in middleware for Server Actions.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert ArrayBuffer to base64 on the client before appending to FormData. Example: const base64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); formData.append('file', base64); Then decode in the Server Action: const buffer = Buffer.from(base64, 'base64');",
      "success_rate": 0.8,
      "how": "Convert ArrayBuffer to base64 on the client before appending to FormData. Example: const base64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); formData.append('file', base64); Then decode in the Server Action: const buffer = Buffer.from(base64, 'base64');",
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrap the ArrayBuffer in a File object before appending to FormData. Example: const file = new File([arrayBuffer], 'filename.bin'); formData.append('file', file); The Server Action will receive it as a File object.",
      "success_rate": 0.85,
      "how": "Wrap the ArrayBuffer in a File object before appending to FormData. Example: const file = new File([arrayBuffer], 'filename.bin'); formData.append('file', file); The Server Action will receive it as a File object.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Instead of using a Server Action, send the data via a fetch POST request to an API route that accepts binary data directly.",
      "success_rate": 0.75,
      "how": "Instead of using a Server Action, send the data via a fetch POST request to an API route that accepts binary data directly.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在客户端将 ArrayBuffer 转换为 base64 再附加到 FormData。示例：const base64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); formData.append('file', base64); 然后在服务端操作中解码：const buffer = Buffer.from(base64, 'base64');",
    "在附加到 FormData 之前将 ArrayBuffer 包装在 File 对象中。示例：const file = new File([arrayBuffer], 'filename.bin'); formData.append('file', file); 服务端操作将接收到一个 File 对象。",
    "不使用服务端操作，而是通过 fetch POST 请求将数据发送到直接接受二进制数据的 API 路由。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/api-reference/functions/server-actions",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}