How do you get file URL with Google Drive Node

Hello everybody,

I am reading messages from Gmail and I send attachments to Google Drive.

From there, I want to get the file link in GDrive to send it to Airtable or Google Sheet.

Does anyone know how to do it ?

Thanks a lot

Welcome to the community @abdoulaye!

I just checked and I do not think that is currently not possible. Looks like there is something wrong and so the “fields” option does not get displayed. For that reason is it currently not possible to select the field you require.

We will have a look and repair it. With some luck, we can release the fix it with the next version on Monday.

Just to let you know that I made some progress on my issue :

I used Write Binary File and Execute Command to save attachments on n8n serveur and upload the files to File.io (as suggested by @maxT in another discussion). It works fine : I can send an temporary url to Airtable !

The only problem is that Airtable doesn’t recognize this url in its attachment field and throw an error. I think it’s because this url from File.io is not direct.

Hence, I’m still interested to use Google Drive to get a real public url.

This is my workflow :

{
  "nodes": [
    {
      "parameters": {
        "resource": "message",
        "operation": "getAll",
        "limit": 5,
        "additionalFields": {
          "labelIds": [
            "INBOX"
          ],
          "q": "=from:[email protected]"
        }
      },
      "name": "Gmail",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [
        210,
        310
      ],
      "credentials": {
        "gmailOAuth2": "Gmail ID"
      }
    },
    {
      "parameters": {
        "keepOnlySet": true,
        "values": {
          "string": [
            {
              "name": "Profile",
              "value": "={{$node[\"Gmail\"].json[\"subject\"].substring(37)}}"
            },
            {
              "name": "Email",
              "value": "={{$node[\"Gmail\"].json[\"text\"].match(/([a-zA-Z0-9._-][email protected][a-zA-Z0-9._-]+\\.[a-zA-Z0-9._-]+)/i)[0]}}"
            },
            {
              "name": "Date",
              "value": "={{$node[\"Gmail\"].json[\"date\"].match(/(\\d{4}-\\d{2}-\\d{2}).+(\\d{2}:\\d{2})/i)[0].replace(\"T\",\" \")}}"
            },
            {
              "name": "Name",
              "value": "={{$node[\"Gmail\"].json[\"text\"].match(/(M[^:]*(?=Email))/gm)[0]}}"
            },
            {
              "name": "PostalCode",
              "value": "={{$node[\"Gmail\"].json[\"text\"].match(/(?<=Place : )\\d{4,5}/gm)[0]}}"
            },
            {
              "name": "City",
              "value": "={{$node[\"Gmail\"].json[\"text\"].match(/\\d{4,5}\\s(.*)\\s/i)[1].toUpperCase()}}"
            },
            {
              "name": "Experience",
              "value": "={{$node[\"Gmail\"].json[\"text\"].match(/([\\w\\s+]{5})?[\\d-]{1,5}\\sans?/i)[0]}}"
            },
            {
              "name": "Skills",
              "value": "={{$node[\"Gmail\"].json[\"text\"].match(/(?<=Skills: ).*/i)[0]}}"
            },
            {
              "name": "Resume",
              "value": "={{$node[\"Execute Command\"].json[\"stdout\"].match(/https[^\"]*/i)[0]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        800,
        310
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "application": "appxxxxxxxxxxxxx",
        "table": "Test",
        "options": {}
      },
      "name": "Airtable",
      "type": "n8n-nodes-base.airtable",
      "typeVersion": 1,
      "position": [
        980,
        310
      ],
      "credentials": {
        "airtableApi": "AirTable ID"
      }
    },
    {
      "parameters": {
        "executeOnce": false,
        "command": "=curl -F \"[email protected]{{$node[\"Write Binary File\"].json[\"fileName\"]}}\" https://file.io"
      },
      "name": "Execute Command",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        590,
        310
      ]
    },
    {
      "parameters": {
        "fileName": "=/Absolute/Path/to/Folder/{{$node[\"Gmail\"].json[\"text\"].match(/(?<=M )[^:]*(?=Email)/)[0].replace(/\\s/g,\"\")}}_{{$node[\"Gmail\"].binary.attachment_0.fileName}}",
        "dataPropertyName": "attachment_0"
      },
      "name": "Write Binary File",
      "type": "n8n-nodes-base.writeBinaryFile",
      "typeVersion": 1,
      "position": [
        400,
        310
      ]
    }
  ],
  "connections": {
    "Gmail": {
      "main": [
        [
          {
            "node": "Write Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "Airtable",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Command": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Binary File": {
      "main": [
        [
          {
            "node": "Execute Command",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Checking the issue with the Google Drive node today.

@abdoulaye ok, now you should be able to retrieve all the file data when uploading. With regard to your use case, the property you need is called webContentLink. Just make sure the file has permission to be downloaded. You can set the permissions using the file:share operation. It should look something similar to the image below.

We will let you know when is released.

1 Like

Got released with [email protected]

1 Like