I am trying to ingest Excel files (.xlsx) and part of my Nifi flow (the second step) utilizes the preconfigured ConvertExcelToCSV Nifi processor, however, some of the Excel files set off the Zip Bomb detector since they are over the default compression ratio.
I have tried setting ZipSecureFile.setMinInflateRatio() to 0 in the ConvertExceltToCSV.java file found in the\nifi-master\nifi-nar-bundles\nifi-poi-bundle\nifi-poi-processors\src\main\java\org\apache\nifi\processors\poi filepath, however even after resetting Nifi, it still throws the ZipBomb detected error and doesn't convert the .xlsx file I need to CSV.
public void onTrigger(final ProcessContext context, final ProcessSession session) throws ProcessException {
final FlowFile flowFile = session.get();
ZipSecureFile.setMinInflateRatio(0);
if ( flowFile == null ) {
return;
}
final String desiredSheetsDelimited = context.getProperty(DESIRED_SHEETS).evaluateAttributeExpressions(flowFile).getValue();
final boolean formatValues = context.getProperty(FORMAT_VALUES).asBoolean();
final CSVFormat csvFormat = CSVUtils.createCSVFormat(context, flowFile.getAttributes());
//Switch to 0 based index
final int firstRow = context.getProperty(ROWS_TO_SKIP).evaluateAttributeExpressions(flowFile).asInteger() - 1;
final String[] sColumnsToSkip = StringUtils
.split(context.getProperty(COLUMNS_TO_SKIP).evaluateAttributeExpressions(flowFile).getValue(), ",");
final List<Integer> columnsToSkip = new ArrayList<>();
if(sColumnsToSkip != null && sColumnsToSkip.length > 0) {
for (String c : sColumnsToSkip) {
try {
//Switch to 0 based index
columnsToSkip.add(Integer.parseInt(c) - 1);
} catch (NumberFormatException e) {
throw new ProcessException("Invalid column in Columns to Skip list.", e);
}
}
}
...
}
I would like to set the MinInflateRatio to 0 or some other nullifying value so that regardless of the compression ratio, Nifi will still convert the page I need from the workbook into a CSV. Any advice or help would be sincerely appreciated.