MCPcopy
hub / github.com/TaskingAI/TaskingAI / upload_image

Function upload_image

backend/tests/api_services/image/image.py:9–21  ·  view source on GitHub ↗
(payload: Dict)

Source from the content-addressed store, hash-verified

7
8
9async def upload_image(payload: Dict):
10 headers = get_headers(CONFIG.Authentication)
11 async with aiohttp.ClientSession(headers=headers) as session:
12 image_path = payload.get("image")
13 image_name = get_file_name(image_path)
14 data = aiohttp.FormData()
15 data.add_field("image", open(image_path, "rb"), filename=image_name, content_type="application/octet-stream")
16 for key, value in payload.items():
17 if key != "image":
18 data.add_field(key, value)
19 request_url = IMAGE_BASE_URL
20 response = await session.post(request_url, data=data)
21 return ResponseWrapper(response.status, await response.json())
22
23
24async def download_image(url: str):

Callers 2

test_upload_imageMethod · 0.90
test_upload_max_imageMethod · 0.90

Calls 5

get_headersFunction · 0.90
get_file_nameFunction · 0.90
ResponseWrapperClass · 0.90
getMethod · 0.45
jsonMethod · 0.45

Tested by 2

test_upload_imageMethod · 0.72
test_upload_max_imageMethod · 0.72