MCPcopy
hub / github.com/TaskingAI/TaskingAI / upload_file

Function upload_file

backend/tests/api_services/file/file.py:8–23  ·  view source on GitHub ↗
(payload: Dict)

Source from the content-addressed store, hash-verified

6FILE_BASE_URL = f"{CONFIG.BASE_URL}/files"
7
8async def upload_file(payload: Dict):
9 headers = get_headers(CONFIG.Authentication)
10 async with aiohttp.ClientSession(headers=headers) as session:
11 file_path = payload.get('file')
12 file_name = get_file_name(file_path)
13 data = aiohttp.FormData()
14 data.add_field('file',
15 open(file_path, 'rb'),
16 filename=file_name,
17 content_type='application/octet-stream')
18 for key, value in payload.items():
19 if key != "file":
20 data.add_field(key, value)
21 request_url = FILE_BASE_URL
22 response = await session.post(request_url, data=data)
23 return ResponseWrapper(response.status, await response.json())

Calls 5

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