|
@@ -1,5 +1,6 @@
|
|
|
#!/usr/bin/env python3
|
|
|
# -*- coding: utf-8 -*-
|
|
|
+import io
|
|
|
import json
|
|
|
import operator
|
|
|
import os
|
|
@@ -1267,10 +1268,23 @@ class DeviceManagement(View):
|
|
|
except:
|
|
|
return response.json(444, 'config必须是一个json数据')
|
|
|
form_data["config"] = json.dumps(config)
|
|
|
+
|
|
|
+ # 每次循环都重新读取文件内容并构造新的文件对象
|
|
|
+ if files:
|
|
|
+ files.seek(0)
|
|
|
+ file_content = files.read()
|
|
|
+ files_for_post = {'iconFile': ('icon.png', io.BytesIO(file_content), files.content_type)}
|
|
|
+ else:
|
|
|
+ files_for_post = {}
|
|
|
+ if files_v2:
|
|
|
+ files_v2.seek(0)
|
|
|
+ file_content_v2 = files_v2.read()
|
|
|
+ files_for_post['iconV2File'] = ('iconV2.png', io.BytesIO(file_content_v2), files_v2.content_type)
|
|
|
+
|
|
|
# 发送 POST 请求调用 add_app_device_type 方法
|
|
|
response_value = requests.post(url + "/deviceManagement/addAppDeviceType",
|
|
|
data=form_data,
|
|
|
- files={'iconFile': files, 'iconV2File': files_v2})
|
|
|
+ files=files_for_post)
|
|
|
return_value = {region: response_value.json()["data"]}
|
|
|
return_value_list.append(return_value)
|
|
|
except Exception as e:
|