Google Drive Integration [GOT CREATED]

An integration for Google Drive should be added:

Any update on this Jan ?

It’s really needed :pray:

Mehdi

Ah yes, had planned to look into it tomorrow.

1 Like

Sorry was to much other stuff going on. Hope I will find some time on friday.

Ok started to work on it. What functionality is needed most? Simply up- and downloading files by ID?

Did not hear back about the functionality so implemented for now just the basics (upload, download, list).

Got released with [email protected]

Remember that you have to invite also here the Service-Account-User to the folders that he can access them because for Google you and the Service-Account-User are two separate entities.

Hello jan,

Sorry I just saw your replies.

For my use case it needs to be able to create folders and documents too, my goal is to deploy a new client folder on google drive, and create a google doc and spreadsheet inside of it.

@vlom31 Ok then you are good to go. The integration already includes the functionality to create folders.

@jan, I’d like to be able to copy a file from one google drive folder to another, and ideally rename it to something else on the way. What would be the best way to do that currently?

My goal is to have something like this:

  1. Workflow started by webhook
  2. New file name created from data in webhook
  3. Template Google Doc copied from Directory A to Directory B
  4. Copied Template Doc renamed with name from step 2
  5. Get link to new Doc

Should I use 2 nodes, one for download, 1 for upload, or will those break the file format? The document is in GDOC format, and I’d like it to stay that way, otherwise it is not worth automating.

You should be able to do it with two nodes. One which downloads it and one with uploads the file with the new name.

So like this, you just have to set the correct file-id in the first node and the new file name in the second:
(you can copy & paste it directly in n8n)

{
  "nodes": [
    {
      "parameters": {
        "operation": "download",
        "fileId": "ID OF FILE",
        "options": {}
      },
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 1,
      "position": [
        377,
        454
      ],
      "credentials": {
        "googleApi": ""
      }
    },
    {
      "parameters": {
        "name": "NEW FILE NAME",
        "parents": [],
        "binaryData": true,
        "options": {}
      },
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 1,
      "position": [
        527,
        454
      ],
      "credentials": {
        "googleApi": ""
      }
    }
  ],
  "connections": {
    "Google Drive": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Right, but the challenge there is it downloads the GDOC as a Microsoft word file, which ends up breaking some of the formatting inside it.
After exploring the Google API a bit, how challenging do you think it would be to add these two API actions:
File: copy (make a copy of the file in the same directory) https://developers.google.com/drive/api/v2/reference/files/copy
Parents: insert (move file to another Google Drive directory) https://developers.google.com/drive/api/v2/reference/parents/insert
I was just able to test these two in the API explorer on those pages, and they do exactly this!

I can have a look. It should not be that hard to add but sadly do not know when I will get to it. Do my best to get to it soon!

Thank you! Also just realized these links are for the v2 API. Not sure which version you are using, but these would be v3:
Copy: https://developers.google.com/drive/api/v3/reference/files/copy
Update parent: https://developers.google.com/drive/api/v3/reference/files/update

1 Like

@jan Have you been able to look into this yet? It’d be super appreciated, and could add a ton of functionality to n8n overall, since so many people use Google Drive!

Sorry not yet. But now I should finally have more time so will hopefully get to it the next few days.

Got added and released with [email protected]

Only added the “copy” function for now as it allows to directly set the new name and new parent.

1 Like