ERR_FR_MAX_BODY LENGTH_EXCEEDED on http post

hi all,
i got an error with big file (30Mo+) on http post, image file
ERR_FR_MAX_BODY_LENGTH_EXCEEDED

our env,
nginx limit 1Go
export N8N_PAYLOAD_SIZE_MAX=64

the goal is to read files on source1 (from url), change name, calc size, and write on source2
after change payload size max i can read big files, change the name, without error, but
on http post to the source 2
i got this error with this file

https://dam.coreplighting.com:8443//razuna/assets/1/25BFDEFB126D45DF98C87E7C0D30F19E/img/EBA6F1CA0C3243F0B408DC86D31C8039/91922_suspension_PLAYA.3L.jpg

[

{

"error": {

"message": "Request body larger than maxBodyLength limit",

"name": "Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]",

"stack": "Error [ERR_FR_MAX_BODY_LENGTH_EXCEEDED]: Request body larger than maxBodyLength limit at RedirectableRequest.write (/opt/n8n/app/node_modules/follow-redirects/index.js:102:24) at FormData.ondata (node:internal/streams/legacy:20:31) at FormData.emit (node:events:390:28) at FormData.CombinedStream.write (/opt/n8n/app/node_modules/combined-stream/lib/combined_stream.js:138:8) at FormData.CombinedStream._pipeNext (/opt/n8n/app/node_modules/combined-stream/lib/combined_stream.js:126:8) at FormData.CombinedStream._realGetNext (/opt/n8n/app/node_modules/combined-stream/lib/combined_stream.js:99:10) at FormData.CombinedStream._getNext (/opt/n8n/app/node_modules/combined-stream/lib/combined_stream.js:82:12) at FormData.CombinedStream.resume (/opt/n8n/app/node_modules/combined-stream/lib/combined_stream.js:154:10) at FormData.CombinedStream.pipe (/opt/n8n/app/node_modules/combined-stream/lib/combined_stream.js:66:8) at dispatchHttpRequest (/opt/n8n/app/node_modules/axios/lib/adapters/http.js:326:10)",

"code": "ERR_FR_MAX_BODY_LENGTH_EXCEEDED"

}

}

]

simple workflow


Thanks for help

i find this but don’t know how to use it

Hi @Christel_Doudet,

You could use axios directly through a Function node when setting the NODE_FUNCTION_ALLOW_EXTERNAL=axios variable (see Environment Variables | Docs for a full list of all variables). @RicardoE105 posted an example in Upload File: Multipart-formdata - #8 by RicardoE105.

You could also force the HTTP Request node to use the old requests library by setting N8N_USE_DEPRECATED_REQUEST_LIB=true to see if this works with your file.

1 Like

Hi @MutedJam ,
thanks, i thought that the problem was a redirect from N8N to axios, i will try to use axios directly,
so :
env variables, ok

const axios = require('axios');

for the function with unlimited length i found this

const result = await axios({
   url: `the url`,
   headers: {
      'Authorization': `Bearer ${auth_token}`,
      'Content-Type': 'application/json'
   },
   method: 'post',
   data: {
      'ParentId': record_id,
      'Name': file_name,
      'body': body,
      'Description': description ? description : "",
      'maxContentLength': Infinity,
      'maxBodyLength': Infinity
   }
});

now my question is how i can link my precedent node and send the file ?:

{
  "nodes": [
    {
      "parameters": {
        "url": "={{$node[\"Set\"].json[\"raz_url\"]}}",
        "responseFormat": "file",
        "dataPropertyName": "image",
        "options": {}
      },
      "name": "GET RAZ Image Data1",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1219,
        415
      ],
      "alwaysOutputData": true,
      "continueOnFail": true
    }
  ],
  "connections": {}
}

If your file lives comes through a binary property data, you could reference the file content using: items[0].binary.data.data. Here’s an example in which I am doing this which I had laying around (just replace the URL with a new one from hookbin.com or a similar service if you want to see it working). It’s not quite what you’re looking for since it uses request-promise-native (and a much smaller file), but it still shows nicely how to reference binary data in the Function node:

{
  "name": "Multipart Form-Data Upload",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const rp = require('request-promise-native');\nconst data = await rp({\n  method: 'POST',\n  uri: 'https://hookb.in/YVndjZrz0GhQERGGEkd7',\n  formData: {\n    file: {\n      value: items[0].binary.data.data,\n      options: {\n        filename: items[0].binary.data.fileName,\n        contentType: items[0].binary.data.mimeType\n      }\n    },\n    name: 'Foo',\n    headline: 'Bar'\n  },\n  headers: {\n    'Content-Type': 'multipart/form-data'\n  },\n})\nreturn [{\n  json: JSON.parse(data)\n}];"
      },
      "name": "Function",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "url": "https://www.dhs.state.il.us/OneNetLibrary/27897/documents/Initiatives/IITAA/Sample-Document.docx",
        "responseFormat": "file",
        "options": {}
      },
      "name": "Get Example File",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get Example File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Example File": {
      "main": [
        [
          {
            "node": "Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "id": 1109
}

I am unfortunately fairly busy with other stuff today, but if you’re struggling with making your axios request, leave a comment on this and I’ll try to put a similar example together for axios tomorrow unless someone beats me to it.