Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Information Provided
-
3.10.0
-
Novice
Description
When I use includeExt=zip to filter files in FTP component, it not worked as I expected.
If I have a file named aaa.bbb.ccc.zip, it will get "bbb.ccc.zip" as the extension, which I expected was "zip".
From the code of GenericFileConsumer<T>.isMatched in camel-file I found that
if (includeExt != null) { String ext = FileUtil.onlyExt(file.getFileName()); boolean any = false; for (String include : includeExt) { any |= include.equalsIgnoreCase(ext);. } if (!any) { return false; } }
Class FileUtil from camel-util:
public static String onlyExt(String name) { return onlyExt(name, false); } public static String onlyExt(String name, boolean singleMode) { if (name == null) { return null; } name = stripPath(name); // extension is the first dot, as a file may have double extension such as .tar.gz // if single ext mode, then only return last extension int pos = singleMode ? name.lastIndexOf('.') : name.indexOf('.'); if (pos != -1) { return name.substring(pos + 1); } return null; }
May be we should change "String ext = FileUtil.onlyExt(file.getFileName());" to "String ext = FileUtil.onlyExt(file.getFileName(), true);" or add an "singleMode" parameter for compatibility。