Camel
  1. Camel
  2. CAMEL-6219

FTPOperations changeCurrentDirectory uses local OS path separator, instead of FTP Server. File upload fails.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Not A Problem
    • Affects Version/s: 2.10.4
    • Fix Version/s: None
    • Component/s: camel-ftp
    • Labels:
      None
    • Environment:

      Windows 7 with Oracle Java 6 JDK
      Remote vsftpd server on a Redhat based Linux distribution

    • Estimated Complexity:
      Unknown

      Description

      Summary:
      When uploading a single file to a vsftpd server from Windows using a Camel ftp:// endpoint results in a 550 Failed to change directory error.
      Likely because the changeCurrentDirectory() command in FTPOperations doesn't provide the server pathSeparator when compacting the url.

      Recreate:

      • Start a vsftpd server (this likely affects other FTP servers) in a *nix environment.
      • Set log4j properties to TRACE for Camel
      • In Windows, run a simple Java class that includes the following
        ProducerTemplate pt = camelContext.createProducerTemplate();
        pt.sendBody("ftp://user@host/subfolder?fileName=test.file&password=12345678&stepwise=false&separator=UNIX");

      Trace:
      [2013.03.27 14:53:56] [main] TRACE FtpOperations - buildDirectory(test)
      [2013.03.27 14:53:56] [main] TRACE FtpOperations - changeCurrentDirectory(/var/ftp/pub)
      [2013.03.27 14:53:56] [main] TRACE FtpOperations - Changing directory: \var\ftp\pub
      [2013.03.27 14:53:56] [main] WARN RemoteFileProducer - Writing file failed with: File operation failed: 550 Failed to change directory.
      Cannot change directory to: \var\ftp\pub. Code: 550

      As you can see the path swaps from /var/ftp/pub to \var\ftp\pub which is the wrong path separator!

      Likely location:
      org.apache.camel.component.file.remote.FTPOperations:656
      path = FileUtil.compactPath(path);
      org.apache.camel.util.FileUtil:209
      return compactPath(path, File.separatorChar);

      File.separatorChar would return the LOCAL OS path, not the REMOTE OS path.
      This should use the value specified by separator=UNIX ("/" not "\").

      Possible fix would be to use the other compactPath(path,separator) method.

      Result:
      You cannot upload a single file using FTP in this fashion from a Windows client to a vsftpd server on Linux. I'll have to switch to an alternative product for ftp until this is resolved, but look forward to returning to using Camel for FTP uploads in the future

        Activity

          People

          • Assignee:
            Claus Ibsen
            Reporter:
            Mark Richards
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development