I tried to put the image uri to data property at inlineData
but it gives me an error like this:
Invalid value at ‘contents[0].parts[0].inline_data.data’ (TYPE_BYTES), Base64 decoding failed for "data:image/jpeg;base64
even if the image uri is correct
Welcome to the forum.
That’s because the URI itself isn’t in fact data of mime type image/jpeg
; once base64-decoded, it is just a small piece of text. To get the effect you want, a Part containing inlineData
, first download the image to your client (use some temporary file storage like /tmp if you don’t intend to keep it), then read the bytes from the image file, and give that to the prompt (in a Part, which you probably already do).
That will work. Hope that helps.
How can I download the image that is coming from the camera I took the photo?
I was using react native on expo.
And it gives me a URI of the image after I capture the image