Ver Fonte

音频文件设备类型符合上传类型

linhaohong há 5 meses atrás
pai
commit
ac88304723
1 ficheiros alterados com 10 adições e 4 exclusões
  1. 10 4
      AdminController/DeviceManagementController.py

+ 10 - 4
AdminController/DeviceManagementController.py

@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 import json
 import operator
+import os
 import threading
 import time
 
@@ -1775,18 +1776,23 @@ class DeviceManagement(View):
         language = request_dict.get('language', None)
         uid = request_dict.get('uid', None)
         channel = request_dict.get('channel', 1)
-        device_types = request_dict.get('deviceTypes', "")
+        device_types = request_dict.get('deviceTypes', None)
         voice_file = request.FILES.get('voiceFile', None)
 
         if not all([title, voice_type, classification, algorithm_type, status, language, voice_file]):
             return response.json(444)
         try:
-            device_type_list = device_types.split(',')
-            device_type_list = list(map(int, device_type_list))
+            if device_types:
+                device_type_list = device_types.split(',')
+                device_type_list = list(map(int, device_type_list))
+            else:
+                device_type_list = []
             classification = int(classification)
             auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
             bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'ansjer-static-resources')
-            filename = CommonService.createOrderID() + ".g711a"
+            file_name = voice_file.name
+            file_extension = os.path.splitext(file_name)[1]
+            filename = CommonService.createOrderID() + file_extension
             voice_prompt_dict = {
                 "title": title,
                 "type": voice_type,