处理上传腾讯电子签图片超过 20 张的情况

FFIB преди 8 месеца
родител
ревизия
80dde28ccd
променени са 1 файла, в които са добавени 11 реда и са изтрити 1 реда
  1. 11 1
      utils/tencentcloud/ess.py

+ 11 - 1
utils/tencentcloud/ess.py

@@ -35,7 +35,17 @@ def test_upload_document_files(files, file_type='png'):
35 35
 
36 36
 
37 37
 def upload_document_files(files, file_type='png'):
38
-    return upload_files(files, file_type=file_type, business_type='DOCUMENT')
38
+    _files = files
39
+    field_ids = []
40
+
41
+    # 腾讯电子签接口限制 20 张图片
42
+    while len(_files) > 20:
43
+        _files = _files[:20]
44
+        res = upload_files(_files, file_type=file_type, business_type='DOCUMENT')
45
+        field_ids = field_ids + res.FileIds
46
+        _files = _files[20:]
47
+        
48
+    return field_ids
39 49
 
40 50
 
41 51
 def upload_files(files, file_type='png', business_type='DOCUMENT'):