Is it possible overwrite or not the same file using Google Drive node?

Describe the issue/error/question

I am reading emails using IMAP node. I am filtering the emails with attached files and I save them in a Google Drive folder. But I want to decide if each file is overwrite or not in case that already exists. Is it possible to do it?

What is the error message (if any)?

I don’t receive any error message, but always the files are created again without overwrite. So if I run 3 times the workflow and the emails have 3 attached files, then I have 9 files at the end in the google drive folder.

Please share the workflow

Share the output returned by the last node

N/A

Information on your n8n setup

  • **n8n version:**0.182.0
  • **Database you’re using (default: SQLite):**N/A
  • **Running n8n with the execution process [own(default), main]:**own
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]:**desktop app

Hi @franchogarcia, the Google Drive node doesn’t have a “upload file only if no file with the same name exists” feature I am afraid.

So you’d first need to check if the file you’re looking for already exists in Google Drive and then decide whether you want to upload it again.

Hi @MutedJam, first at all thank you for your help. Always it is appreciated.
I am trying to resolve it from two ways but in both cases and I haven’t been able to achieve. I am gonna try to explain you:

CASE 1:
I am trying to find the file using Google Drive node. To do that I am using Query String like the next:

parentid='14RpuFcMOJimK51csxtY0h1K6OBmlopsE' and name='1IiDi90KkqeTdbqyzkGYdV9jz3TZCrWwJ

but I suppose that it is not possible to do it or I am do it wrong because not runs.

CASE 2:
I am saving the files in a table and I am trying to check if exists into the table or not. The idea after that is that if the file exist then I will decide to overwrite it using update operation of Google Drive node or to create another one to have a historical of file with the upload operation of Google Drive node.
The problem that I having with this solution is that when the query to the table not returns nothing means that I must upload the file but due the mysql node not returns nothing, I have no idea over what file I must do it. I know that I explain very bad :sweat_smile: but do you understand me?

I think that the best solution for me is the second, but I have not idea how to resolve it. Could you help me please?:pray:

Thank you very much for your time and support!!
Always I am very thankful to you!
BR!

I am trying to find the file using Google Drive node. To do that I am using Query String like the next:

parentid='14RpuFcMOJimK51csxtY0h1K6OBmlopsE' and >name='1IiDi90KkqeTdbqyzkGYdV9jz3TZCrWwJ

I think the query might need a little change. From looking at Search query terms and operators  |  Drive API  |  Google Developers it seems the parent would need to be queries using parents in. I tried the below query and it worked fine:

parents in '1wMIWHmMR-AHsZTDXkrWd0q4vUenaeVRi' and name = '{{$json["filename"]}}'

1 Like

Thank you a lot. Run perfectly!!
You are the best!!

1 Like

Awesome, glad to hear! Thanks so much for confirming :smiling_face:

1 Like