4

I am attempting to use the secure FTP ColdFusion functionality. I am running into an error with the fileExists function, only when using a secure connection. Instead of returning "no" when a file passed in doesn't exist it instead errors saying:

"An error occurred during the sFTP existsFile operation.

The system cannot find the path {file name}"

Picture of the error

The regular FTP stuff works perfectly (same code as below but different connection).

If the file does exist, then there is no problem and the file is deleted and written.

I feel this is a bug, but I am confirming that I am not doing something wrong or missing something.

<cfftp action="open"
    connection="ftp_connection"
    server="#this.server#"
    port="#this.port#"
    username="#this.username#"
    password="#this.password#"
    fingerprint="#this.fingerprint#"
    secure="yes"
    />

<cfftp action="existsFile"
    connection="ftp_connection"
    remotefile="#arguments.remote_name#"
    directory="/"
    />

  <cftry>
    <cfif cfftp.returnValue EQ "Yes" or cfftp.returnValue EQ "true">
      <cfftp action="remove" 
        connection="ftp_connection"
        item="#arguments.remote_name#"
        />
    </cfif>

    <cfftp action="putFile"
      connection="ftp_connection"
      passive="true"
      localfile="#ExpandPath('/vctemp/#arguments.local_name#')#"
      remotefile="#arguments.remote_name#"
      />
Leigh
  • 28,765
  • 10
  • 55
  • 103
  • Out of curiousity, have you tried the existsFile without the directory attribute? Or by executing a changeDir operation before the existsFile operation and ensuring your arguments.remote_name is just a filename with no directory? Where you write "If the file does exist, then there is no problem", I assume you're referring to success with SFTP and not just the plain FTP test mentioned above? I read it as SFTP but if not then I'd suggest verifying the SFTP connection before the existsFile either by testing cfftp.succeeded returns true after the "open" or by using stopOnError="yes" when opening. – Sev Roberts Oct 20 '15 at 14:46
  • Yeah I originally had it without the directory attribute. Adding that in was an attempt to work around this issue. Also I actually do check if the connection was successful, but I truncated the code for that as it seemed unimportant for the issue. – Cody Bellitto Nov 10 '15 at 14:14

0 Answers0