My Python RESTAPI bootstrap template sends a POST request using fetch
to blueprint endpoint as multipart/form-data. How to process that files["image"]
into the contents
field of a multimodal request to Gemini API without using PIL Image? Text generation | Gemini API | Google AI for Developers doesn’t show how to do that.
This is the content of the post files["image"]
received at my RESTAPI endpoint:
image: <FileStorage: '1.jpg' ('image/jpeg')>, <class 'quart.datastructures.FileStorage'>
Currently hit this error by using the image directly:
Exception: file uri and mime_type are required
Current workflow according to the docs which doesn’t make sense to me:
(1) Save the data
(2) The API SDK read it from the persistence store again (URI) to send it over to the model to generate text / media
(3) and then clean up the unused file data on the storage.