File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes File Upload Error - Using JSCH/SFTP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "File Upload Error - Using JSCH/SFTP" Watch "File Upload Error - Using JSCH/SFTP" New topic

File Upload Error - Using JSCH/SFTP

Dibyendu Sarkar

Joined: Jan 12, 2009
Posts: 25

I'm using JSCH APIsto upload files to a remote SFTP server. Till now I was running Tomcat on my local system and testing the code so everything was working fine. I could upload the files from the local system to the Remote SFTP location.

Now that the code was deployed to the testing environments, I started getting the following exception: C:\Documents and Settings\User001\Desktop\Testing.txt (No such file or directory)

On printing the canonical path of the file, I found that the filename string that I was passing to the code, was getting the Server's Tomcat Bin directory appended to it!! So the file not found error.

Can anybody tell me please how to make the server look into the client machine's file structure, instead of the server?

Here's the Code to upload:

I'm thinking whatever the cause is, it will make my "Download Attachment" method to fail too, as it will download to the server instead of the client machine.

Note: This code works fine on localhost. So I'm assuming logic and usage of the API is fine.
I agree. Here's the link:
subject: File Upload Error - Using JSCH/SFTP
It's not a secret anymore!