##// END OF EJS Templates
v2.9.2 :: Add 'max_count' option in upload_multiple_files_advance function
eynilupu -
r6:9f9e218fed1d
parent child
Show More
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -150,7 +150,7 class JROAPI():
150 _, exc_value, _ = sys.exc_info()
150 _, exc_value, _ = sys.exc_info()
151 return exc_value
151 return exc_value
152
152
153 def upload_multiple_files_advance(self, dataset_id, path_files, file_date, file_type, max_size=100, ignore_repetition=False, **kwargs):
153 def upload_multiple_files_advance(self, dataset_id, path_files, file_date, file_type, max_size=100, max_count=500, ignore_repetition=False, **kwargs):
154 # Agregar si es interruptido por teclado
154 # Agregar si es interruptido por teclado
155 '''
155 '''
156 FINALIDAD:
156 FINALIDAD:
@@ -230,16 +230,23 class JROAPI():
230 #------------------------------------------------------------#
230 #------------------------------------------------------------#
231 blocks = [[]]
231 blocks = [[]]
232 size_file = 0
232 size_file = 0
233 count_file = 0
233 inter_num = 0
234 inter_num = 0
234 for value in total_list:
235 for value in total_list:
235 if value['size'] > 1048576 * float(max_size):
236 if value['size'] > 1024 * 1024 * float(max_size):
236 return 'ERROR:: The size of the "%s" file is %sMB, please change "max_size" value' % (value['name'], str(round(value['size']/1048576, 1)))
237 return 'ERROR:: The size of the "%s" file is %sMB aprox, please change "max_size" value' % (value['name'], str(round(value['size']/(1024 * 1024), 2)))
238 if not 1 <= int(max_count) <= 999:
239 return 'ERROR:: The count of the number of files must be between 1 and 999, please change "max_count" value'
240
237 size_file = size_file + value['size']
241 size_file = size_file + value['size']
238 if size_file <= 1048576 * float(max_size):
242 count_file = count_file + 1
243 if size_file <= 1024 * 1024 * float(max_size) and count_file <= int(max_count):
239 del value['size']
244 del value['size']
240 blocks[inter_num].append(value)
245 blocks[inter_num].append(value)
241 else:
246 else:
242 inter_num = inter_num + 1
247 inter_num = inter_num + 1
248 size_file = value['size']
249 count_file = 1
243 blocks.append([])
250 blocks.append([])
244 del value['size']
251 del value['size']
245 blocks[inter_num].append(value)
252 blocks[inter_num].append(value)
General Comments 0
You need to be logged in to leave comments. Login now