Difference Between Axios and HTTP Request Node for File Upload

Describe the issue/error/question

Although an image can be uploaded to a custom endpoint via Postman successfully, when I uploaded with HTTP Request node in n8n the jpeg image posting broken.

I couldn’t find why is the HTTP Request node behaving like that but I found a solution via using custom module.

This is the result that uploaded by HTTP Request node

Screen Shot 2022-05-11 at 19.31.16

Here you can find my short function that solves the issue. Also you can find parameters of HTTP node.

Do you have any comment about the issue?

n8n Setup

  • n8n version: 0.171.1
  • Database you’re using: MySQL & Redis
  • Running n8n with the execution process: own
  • Running n8n via: Docker

Hey @samaritan, the HTTP Request node would use Axios under the hood (unless you have the N8N_USE_DEPRECATED_REQUEST_LIB environment variable set to true).

Your Function node would upload an empty file for me and I am quite surprised to hear it works for you tbh. Since n8n version 0.135.0 the file buffer should no longer be accessible in the way you describe and instead I would have expected something like const file = await this.helpers.getBinaryDataBuffer(0, 'mydata'); in your code.

Where did you upload the file to using the HTTP Request? It seems to work fine for me when I tested the upload of one my one files, so I wonder if the problem might rather be with the service receiving the data (or the format you have chosen not quite matching what your service expects).

Hi @MutedJam,

Thank you for your support.

I didn’t set the N8N_USE_DEPRECATED_REQUEST_LIB environment variable as true.

Since the service is an internal BE service, I thought it might be related with the service itself. However, when I’ve tried on Postman, I observed that images successfully uploaded. I’ve compared the options and headers of HTTP Request node and Postman, I couldn’t find any difference. Also our software team shared the Front End code with me.

Axios part of code

return publicAxios({
    method: 'PUT',
    url: signedUrl,
    data: binaryData,
  }).then(response => {
    return response.data;

After that I’ve decided to try using Axios in Function node and as you can see in my first post it is uploaded successfully. I’ve also checked with the code that generated by Postman. I’m thinking that can be related with the format of binary?

How HTTP request node handle binary? I’ve used the below code to create Buffer from base64. If the handling of HTTP request node is completely different approach, this may be the answer. It was just an idea, as you can guess I’m not good at programming :smiley:


By the way, I’ve tried to use your code but there is not any function/method as helpers in IntelliSense (I don’t know that this is the correct definition of the feature that helps us to select correct method by fetching all methods after putting “.”)

Screen Shot 2022-05-13 at 00.22.42