Google Gemini image generation - how to change id to base64?

I have a Gemini Image generating but it returns an ID. I believe it is saving the file in a temporary n8n folder - I can preview it fine. How do I retrieve it so I can send it to my other server as a base64 image?
For example, the file id is: filesystem-v2:workflows/ktDakD-X3TnqPTQ8TUeDE/executions/53/binary_data/bfc7698e-a918-4f95-bb8c-18023ABS87c9

Here’s my workflow

Full response from Gemini is

[
{“mimeType”: “image/png”,
“fileType”: “image”,
“fileExtension”: “png”,
“fileName”: “image.png”,
“id”: “filesystem-v2:workflows/ktDakD-X3TnqPTQ8TUeDE/executions/53/binary_data/bfc7698e-a918-4f95-bb8c-18023ABS87c9”,
“fileSize”: “1.27 MB”}
]

Information on your n8n setup

  • n8n version:
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via self-hosted on Hostinger

Hi @TechWizard Welcome Back!
I Hope this question uploaded and answered previously might bring some help:


Hope this helps.

Hi @TechWizard !
Hope you’re doing well. This “filesystem-v2” that appears in the ID is just an internal path where n8n temporarily stores the file. You need to convert it to base64 and send it to another server. You can do this with the ‘extract from file’ node or with node code. If the details aren’t in the post shared above, check the n8n docs, will probably give you the step-by-step instructions.

Hi @TechWizardm welcome!

With the n8n Binary File Body Type, you just need to provide the binary name, like this:

so you can try this:

If you can tell me about your API docs for image uploads, I might be able to help you configure this correctly..

1 Like

Thanks much for the recommendation.

First I tried copying your recommendations to my workflow, then when that didn’t work I tried using your workflow exactly as-is. I tried with the data being both “Fixed” and “Expression” but neither worked. I noticed I had one flaw in the original sample:

“name”: “FileExtension”, “value”: “={{ $(‘Generate an image’).item.json.fileSize }}”

… should be:

“name”: “FileExtension”, “value”: “={{ $(‘Generate an image’).item.json.fileExtension }}”


My PHP page receives the post with the FileSize, Extension, etc. But no data with an image in it.

Thanks Anshul. I am certain your method works but I’m really trying to use the Gemini native node option. I have direct API calls working to generate images on my server… I’m just hoping to utilize the n8n Gemini node.

Is this link using an API? or are you uploading the image in the usual way?
Are there any docs describing the expected parameters?
Could you also share screenshots of what you’re doing and the error you’re getting?

Hi Mohamed,

I’m not receiving any error.

The problem is I haven’t been able to figure out how to get the image passed to my server as a binary file. I have the n8n temporary file location in the id like:

filesystem-v2:workflows/ktDakD-X3TnqPTQ8TUeDE/executions/68/binary_data/d96a7286-ddef-4a42-a0a6-fa61f9e2d9b8

My problem is pulling the binary image from the n8n temporary folder so I can pass it to my web server for storage.

I thought I found the solution as:

{{ $('Generate an image').item.binary.data }}

but that only contains:

[Object: {"mimeType": "image/png", "fileType": "image", "fileExtension": "png", "data": "filesystem-v2", "fileName": "image.png", "id": "filesystem-v2:workflows/ktDakD-X3TnqPTQ8TUeDE/executions/68/binary_data/d96a7286-ddef-4a42-a0a6-fa61f9e2d9b8", "fileSize": "1.1 MB"}]

I understand, but I’m not sure what your server is expecting to receive, so it’s difficult to advise you on the correct method :confused:

You can ignore that file path; it doesn’t work that way in this context.


Here is an example of a normal approach:

However, as I mentioned idk exactly what your server’s upload endpoint expects,
Does it need the binary file?? Base64 string?? only you would know that since those details weren’t shared..

if you just need the base64 you can use the node Extract from File:


1 Like

Thanks @tamy.santos , I think you are correct. I just have not been able to find the exact syntax to make it work.

1 Like

The “Extract from File” was the magic trick I needed.
Thanks so much!!!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.