Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.9k views
in Java FTP by (160 points)
Hi,

I'm using the SSHFTPClient class to upload a file to a third party SFTP server. The connection to the SFTP server is successful and a call to chdir() to change to the upload folder is also successful. But the call to put() to upload the file fails. It throws an FTPException with detailed error message "Specified file path is invalid. : /to_folder".

I've run the same test application against an in-house SFTP server using a different upload folder name (e.g. /home/anne/to_folder). The file upload succeeds in this case.

Any ideas what the problem may be?

Many thanks.
Anne

3 Answers

0 votes
by (162k points)
Can you please set the debug level to ALL (see the Dev Manual) and email the log file to support at enterprisedt dot com? We'll take a look. Thanks.
0 votes
by (160 points)
Bruce, thanks for the verbose logging tip. A tremdous help. I figured out what the problem was by doing a side by side comparison of the log for the successful upload vs the log for the failed upload.

The problem was related to the behaviour of the 3rd party SFTP server. A file written to the /to_folder is deleted *immediately* after the file is closed. The exception was happening on the chmod that happens (by default) after file creation during a put() operation. I resolved it by setting the config flag to disable the permission change made after file create:

sftpClient.setConfigFlags(SSHFTPClient.ConfigFlags.DISABLE_CHMOD_AFTER_PUT);

Interestingly, the file was being uploaded despite the exception. I didn't believe it when the tech contact for the third party SFTP server claimed they received the first file. Makes perfect sense now.

Anne
0 votes
by (162k points)
Great. In the latest version the exception thrown in this situation is caught, and just a warning logged (which can be removed by setting this flag).

I resolved it by setting the config flag to disable the permission change made after file create:

sftpClient.setConfigFlags(SSHFTPClient.ConfigFlags.DISABLE_CHMOD_AFTER_PUT);

Categories

...