Hugging face Api problem text to image

I’m creating a flow where I want to use the Hugging Face API for text-to-image generation (Text to Image). I have everything set up and working in n8n, and I receive the output, but when I try to save the result to Google Drive, I get an error message: “”{“file”:["Expected file url or base64 with mimeType, but found value: “”

I’m a beginner and I’ve been struggling with this for two days, and I couldn’t find any solutions or help online. Does anyone have any suggestions? In n8n, I receive “data” and when I save it, I get the generated image, but here I have “body” which I’m unable to save.

I got same issue :slight_smile:

I found that you received image in raw binary format. I tried to convert it in png and working on code but it’s doesn’t work for now :slight_smile:

You can check this video. He explain about this issue in make.com, but it’s doesn’t work at AP :slight_smile: https://www.youtube.com/watch?v=k9nmOYbZp14

import { Buffer } from 'buffer';

export const code = async (inputs: { imageData: Uint8Array }) => {
  try {
    // Convert the Uint8Array to a Buffer in Node.js
    const buffer = Buffer.from(inputs.imageData);
    // Convert the Buffer to a base64 string
    const base64 = buffer.toString('base64');
    return { base64: `data:image/png;base64,${base64}` };
  } catch (error) {
    throw new Error(`Error saving image: ${error instanceof Error ? error.message : 'Unknown error'}`);
  }
}

I have the same issue.