MCPcopy
hub / github.com/Sophomoresty/gemini-web2api / _upload_images

Function _upload_images

gemini_web2api/server.py:23–40  ·  view source on GitHub ↗

Upload images and return list of file references. Returns None if no images.

(images: list)

Source from the content-addressed store, hash-verified

21
22
23def _upload_images(images: list) -> list:
24 """Upload images and return list of file references. Returns None if no images."""
25 if not images:
26 return None
27 file_refs = []
28 for item in images:
29 try:
30 if isinstance(item, tuple) and len(item) == 2:
31 data, mime = item
32 if isinstance(data, str):
33 data = fetch_image_bytes(data)
34 mime = mime or "image/png"
35 if data:
36 ref = upload_image(data, "image.png", mime or "image/png")
37 file_refs.append(ref)
38 except Exception as e:
39 log(f"Image upload failed: {e}")
40 return file_refs if file_refs else None
41
42
43class GeminiHandler(BaseHTTPRequestHandler):

Callers 3

_handle_chatMethod · 0.85
_handle_responsesMethod · 0.85

Calls 3

fetch_image_bytesFunction · 0.85
upload_imageFunction · 0.85
logFunction · 0.70

Tested by

no test coverage detected