HTTP GET File Issue

I’m having an issue retrieving a .wav file using HTTP GET. The url for file runs a php script to download the file (to mask a direct link to it)

When I try to upload the file to S3, S3 detects the MIME type as .wav, but the file extension as php, like this:
File Request 1

How can I get my workflow to identify this properly? The URL is in this format:
https://OMITTED.com/playback.php?submit=PLAY&accel=sip:OMITTED.com&casid=OMITTED&cccid=FA75&calid=20210622231420005629-53e2e8b165fa5ea7239c5bca5e81391c&uid=OMITTED&time=20210623060001&auth=e5f51411c60fdbb0528cee8b3cd7baad

As a side note, using Integromat I am able to accomplish this without an issue, here’s the HTTP GET request from there:

{
                        "id": 144,
                        "module": "http:ActionGetFile",
                        "version": 3,
                        "parameters": {
                            "handleErrors": false
                        },
                        "mapper": {
                            "url": "{{107.data[].url}}",
                            "method": "get",
                            "shareCookies": false
                        },
                        "metadata": {
                            "designer": {
                                "x": 3000,
                                "y": 0
                            },
                            "parameters": [
                                {
                                    "name": "handleErrors",
                                    "type": "boolean",
                                    "label": "Evaluate all states as errors (except for 2xx and 3xx )",
                                    "required": true
                                }
                            ],
                            "expect": [
                                {
                                    "name": "url",
                                    "type": "url",
                                    "label": "URL",
                                    "required": true
                                },
                                {
                                    "name": "method",
                                    "type": "hidden",
                                    "label": "Method"
                                },
                                {
                                    "name": "shareCookies",
                                    "type": "boolean",
                                    "label": "Share cookies with other HTTP modules",
                                    "required": true
                                }
                            ]
                        }
                    }

Welcome to the community @jhambach

Just checked and we are using the the last part of the URL to set the file name and extension. I had not seem a use case like yours before. Have to check how to fix it.

In the meantime, you can use a function node to rename the file name. Check the example below.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "url": "http://cdn.akc.org/content/article-body-image/samoyed_puppy_dog_pictures.jpg",
        "responseFormat": "file",
        "options": {},
        "headerParametersUi": {
          "parameter": []
        }
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const binaryPropertyName = 'data';\nconst fileName = 'newfilename.jpg'\nconst fileExtention = 'jpg'\n\nconst binaryData = items[0].binary[binaryPropertyName];\n\nbinaryData['fileName'] = fileName;\nbinaryData['fileExtension'] = fileExtention\n\n\nreturn [\n  {\n    json: {},\n    binary: {\n      [binaryPropertyName]: binaryData\n    }\n  }\n]\n\n"
      },
      "name": "Function1",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        710,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Function1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
1 Like

Just wanted to note in case anyone else has this issue, updating to the latest version (0.127.0 for us) of n8n fixed our issue and this works perfectly now.

2 Likes