Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-16745

camel-ftp - excludeExt/includeExt not getting the right filename extension

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Information Provided
    • 3.10.0
    • 3.11.0
    • camel-ftp
    • 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。

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            amuro_lei Huang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 12h
                12h
                Remaining:
                Remaining Estimate - 12h
                12h
                Logged:
                Time Spent - Not Specified
                Not Specified