| 7 | |
| 8 | |
| 9 | async 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 | |
| 24 | async def download_image(url: str): |