Problem uploading multiple files to Google Drive


I’m uploading two files to a newly created drive, both get uploaded successfully but only the first one is getting its parent set:

The expression for “parents” is: {{$node["Google Drive"].json["id"]}}. The actual directory is contained in a team drive.

Is this a bug or am I doing something wrong?

Hey @trygvis,

Does the previous node return two different Parent ID? Or are you trying to upload the files to the same parent?

It seems like, your previous node returns only one Parent ID. n8n takes this input for the item and uploads it. For the next item, since there is no other Parent ID, n8n uploads the file without the Parent ID. If you’re uploading the files to the same ID, you can simply paste the Parent ID and you don’t need an expression. Alternatively, you can use this expression {{$item(0).$node['Google Dirve'].json["ID"]}}. This will use the ID from the previous node for both of your files.

I’m using this expression:

I would expect it to evaluate to the same for all items, does it not?

As I wrote in the original post, I’m creating the folder earlier in the flow and I want to upload both to the same (newly created) folder.

Let me give an example to help you understand how the data flow.

Let’s take your example - I create one folder, fetch 5 files from an API, and I want to upload it to Google Drive. My first Google Drive node (creates folder), returns a single item (since I created a single folder). My next node, HTTP Request node, fetches 5 files from a URL. Now, we have 5 input items for the next node. Since we have only one Parent ID and 5 files, n8n will only be able to use the Parent ID once with the expression that you’re using. To let n8n know that it should use the same Parent ID for all the files, you need to use the expression {{$item(0).$node['Google Dirve'].json["ID"]}}.

I hope this clears your doubt a bit. Let me know if you have further questions.

Very strange, but that works. Thanks.