| 6 | FILE_BASE_URL = f"{CONFIG.BASE_URL}/files" |
| 7 | |
| 8 | async 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()) |