Upload a local image with Google Drive

Hello everyone, I discovered this project for an alternative to IFTTT. It’s amazing how much can be done, great job.

My current project is to retrieve backup notification emails from a gmail box, then send the notifications via webhook to a Google Chat room.

I currently proceed as follows:

  • Cron job
  • Check a directory of a GMAIL mailbox.
  • Transformation of body text (HTML) into binary data.
  • Writing a binary file locally on the machine. (/ Files)
  • Execution of a utility via Execute Command to transform HTML into PNG (wkhtmltoimage, added to docker). (PNG stored in / files)
  • Send the PNG file to a Google Drive account.
  • Creation of a sharing URL for this PNG file.
  • Sends webhook request

I’m currently having a problem sending my file to my Google Drive storage. I was wondering if I could send a local file, or if I had to transform this image into binary data and then send it back to Google Drive.

Is it possible to enlighten me on this?

Hi @antoinesnowleader, welcome to the community. We are very glad that you found us :raised_hands:

You can use the Read Binary File (or Read Binary Files) node to read a local file and then connect it to the Google Drive node to upload it. The workflow could look something like this:

Here’s the workflow:

{
  "nodes": [
    {
      "parameters": {
        "authentication": "oAuth2",
        "binaryData": true,
        "name": "new_name.png"
      },
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "googleDriveOAuth2Api": "Drive"
      }
    },
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "filePath": "hello.png"
      },
      "name": "Read Binary File",
      "type": "n8n-nodes-base.readBinaryFile",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "binaryData": true,
        "name": "new_name.png"
      },
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "googleDriveOAuth2Api": "Drive"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Read Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read Binary File": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

In the workflow above, you’d have to adjust a few things like the File Path in the Read Binary Node and the File Name in the Google Drive node. Hope that helps! :slight_smile:

1 Like

Hi !
Thanks for your quick answer, its working well :slight_smile:

The behaviour on Google Drive is just a little werd :sweat_smile:

gdrive

I’ll see if that’s a problem for me later.

Hey @antoinesnowleader, that shouldn’t happen. This is how it looked for me.

Screenshot 2021-03-30 at 10.50.15 AM

The image that you uploaded, was it a PNG file locally? Does that happen when you upload other image formats as well?

Forget it, during my first test, I was reading the html file, not the png file …
It works perfectly :smiling_face_with_three_hearts:

1 Like

Glad to hear that! Have fun! :slight_smile: