|
@@ -1,6 +1,7 @@
|
|
|
import asyncio
|
|
|
import aiohttp
|
|
|
import time
|
|
|
+import io
|
|
|
import cv2
|
|
|
from logger import logger
|
|
|
from stream import StreamCapture
|
|
@@ -15,8 +16,10 @@ async def upload_image(session, url, payload, files):
|
|
|
form_data.add_field(key, value)
|
|
|
|
|
|
# 添加文件数据
|
|
|
- for filename, content, content_type in files:
|
|
|
- form_data.add_field("file", content, filename=filename, content_type=content_type)
|
|
|
+ for key, (filename, content, content_type) in files:
|
|
|
+ content_io = io.BytesIO(content)
|
|
|
+ content_io.seek(0)
|
|
|
+ form_data.add_field(key, content, filename=filename, content_type=content_type)
|
|
|
|
|
|
# 发起 POST 请求
|
|
|
async with session.post(url, data=form_data) as response:
|
|
@@ -75,8 +78,8 @@ async def process_stream():
|
|
|
}
|
|
|
|
|
|
files = [
|
|
|
- (filename, content, 'image/jpeg'),
|
|
|
- (filenameori, contentori, 'image/jpeg')
|
|
|
+ ('file', (filename, content, 'image/jpeg')),
|
|
|
+ ('oldFile', (filenameori, contentori, 'image/jpeg'))
|
|
|
]
|
|
|
|
|
|
# 使用协程上传图像
|