Upload s3 working but uploads empty file

I am trying to upload binary data to s3 after download from HTTP request…
Its working from my local and from postman
but when i am trying call the webhook from dev server it simply upload an empty file. Although same works fine when i call the webhook from postman or my local app.

Welcome to the community @Amit_Bhattacharjee !

Can you please share the workflow.

{
  "name": "",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "box/download",
        "responseMode": "lastNode",
        "options": {
          "rawBody": false
        }
      },
      "name": "Download_File",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        502,
        305
      ],
      "webhookId": "08c39f29-5ee4-4180-bf9a-7d53016ba671"
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "=https://api.box.com/2.0/files/{{$node[\"Download_File\"].json[\"body\"][\"fileId\"]}}/content",
        "responseFormat": "file",
        "options": {}
      },
      "name": "Download API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        722,
        305
      ],
      "alwaysOutputData": true,
      "executeOnce": true,
      "credentials": {
        "httpHeaderAuth": "Header Auth 4"
      }
    },
    {
      "parameters": {
        "operation": "upload",
        "bucketName": "={{$node[\"Download_File\"].json[\"body\"][\"aws\"][\"bucket\"]}}",
        "fileName": "={{$node[\"Download_File\"].json[\"body\"][\"inputFile\"]}}",
        "additionalFields": {},
        "tagsUi": {
          "tagsValues": []
        }
      },
      "name": "S3",
      "type": "n8n-nodes-base.s3",
      "typeVersion": 1,
      "position": [
        922,
        305
      ],
      "credentials": {
        "s3": "aws s3"
      }
    }
  ],
  "connections": {
    "Download_File": {
      "main": [
        [
          {
            "node": "Download API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download API": {
      "main": [
        [
          {
            "node": "S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {}
}
{
  "name": "",
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "box/download",
        "responseMode": "lastNode",
        "options": {
          "rawBody": false
        }
      },
      "name": "Download_File",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        502,
        305
      ],
      "webhookId": "08c39f29-5ee4-4180-bf9a-7d53016ba671"
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "=https://api.box.com/2.0/files/{{$node[\"Download_File\"].json[\"body\"][\"fileId\"]}}/content",
        "responseFormat": "file",
        "options": {}
      },
      "name": "Download API",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        722,
        305
      ],
      "alwaysOutputData": true,
      "executeOnce": true,
      "credentials": {
        "httpHeaderAuth": "Header Auth 4"
      }
    },
    {
      "parameters": {
        "operation": "upload",
        "bucketName": "={{$node[\"Download_File\"].json[\"body\"][\"aws\"][\"bucket\"]}}",
        "fileName": "={{$node[\"Download_File\"].json[\"body\"][\"inputFile\"]}}",
        "additionalFields": {},
        "tagsUi": {
          "tagsValues": []
        }
      },
      "name": "S3",
      "type": "n8n-nodes-base.s3",
      "typeVersion": 1,
      "position": [
        922,
        305
      ],
      "credentials": {
        "s3": "aws s3"
      }
    }
  ],
  "connections": {
    "Download_File": {
      "main": [
        [
          {
            "node": "Download API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download API": {
      "main": [
        [
          {
            "node": "S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {}
}

look into the last one

Settings look generally correct on HTTP Request and AWS S3 node. Are you sure that the file that gets downloaded via the HTTP Request node is not empty already?

Is there a reason for using the HTTP Request node for downloading the file instead of the native Box Node?

Yes the file is downloading correctly and working when i call the webhook from my local postman, or from my local application.

Only problem when i am calling from staging server, the file downloaded and uploaded to s3 is empty

So the problem is then not uploading, the problem is that already the downloaded file is empty.

Then again back to my previous question. Why do you not use the Box-Node?

i am not using Box-Node because box authentication is done from the application and token information saved to our aws ssm so we create a n8n-webhook which called from our application and pass the access_token to connect to box api and download file and then upload the downloaded file to s3 bucket.

Now the problem is that file has data but when it’s trying to uploading to s3 bucket its uploads an empty file.
When i call the same webhook from postman and my local app which is running in nodejs its working fine for the same file request.
So problem only happening whenever the webhook request called from staging or dev(uat) server

Ok, because you wrote: “the file downloaded and uploaded to S3 is empty”.
That sounded for me, like the file that gets downloaded is already empty and the problem was there.

The thing is that is also the only explanation I could have. Just because it is working correctly when you download it with Postman does not really mean that the download did also work in this case in n8n. Do you see the file content in the n8n editor? Or did you try to save the file with the “Write Binary File Node” to disk and you confirmed there that it has content?

I just tested uploading a file to S3 and downloaded it again. The file was not empty for me.

Hi @jan . I am interested in this discussion. How would one go about debugging issues like this? Please advise.

Welcome to the community @prashant

Download a file with the HTTP node and then upload it using the S3 node. Then, go to the AWS S3 UI and download it. If the file opens up correctly, then it works. At least, that is what I would do.