diff --git a/ui-admin/src/core-plugins/admin/1/as/services/xls-import/xls-import.py b/ui-admin/src/core-plugins/admin/1/as/services/xls-import/xls-import.py index 631c5649d7a3c92253329e0daf22ab8e16e3df16..990f5c00ef6084d704acd6ea5990b8cded5b6094 100644 --- a/ui-admin/src/core-plugins/admin/1/as/services/xls-import/xls-import.py +++ b/ui-admin/src/core-plugins/admin/1/as/services/xls-import/xls-import.py @@ -55,7 +55,15 @@ def process(context, parameters): temp.mkdir() tempPath = temp.getAbsolutePath() MasterDataRegistrationHelper.extractToDestination(zip_bytes, tempPath) + if (len(temp.listFiles()) == 1): + singleFile = temp.listFiles()[0] + if (singleFile.isDirectory()): + temp = singleFile + tempPath = singleFile.getAbsolutePath() byteArrays = MasterDataRegistrationHelper.getByteArrays(Path.of(tempPath), ".xls") + byteArrays.addAll(MasterDataRegistrationHelper.getByteArrays(Path.of(tempPath), ".xlsx")) + if len(byteArrays) == 0: + raise UserFailureException('No .xls or .xlsx fields found. These should be on the root folder of the zip file.') parameters.put('xls', byteArrays) allScripts = MasterDataRegistrationHelper.getAllScripts(Path.of(tempPath)) parameters.put('scripts', allScripts)