This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Trying to upload a file through jscape sftp API in java and not able to set the default directory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Trying to upload a file through jscape sftp API in java and not able to set the default directory" Watch "Trying to upload a file through jscape sftp API in java and not able to set the default directory" New topic
Author

Trying to upload a file through jscape sftp API in java and not able to set the default directory

deepak jaiswal
Greenhorn

Joined: May 25, 2011
Posts: 1
Hi all,

I am trying to upload a file from local system to a remote system using jscape SFTP API.
As while upload i need to create a directory to store my file and if i am setting this created folder
as root folder for upload i m getting resource access denied.
Find the below code .....

try {

// create new SshParameters instance
SshParameters params = new SshParameters(ftpHostname,ftpUsername,ftpPassword);

// create new Ftp instance
Sftp ftp = new Sftp(params);

// establish secure connection
ftp.connect();
ftp.makeDir("SFTPPath");
ftp.setDir("D:/FTP/SFTPPath");
ftp.upload("D:/temp/uploads/New Text Document.txt");

// disconnect
ftp.disconnect();

}
catch(Exception e) {
e.printStackTrace();
}

At the remote machine the sftp server is configured for the default root directory as D:/FTP.
The folder is created but if trying to cal setDir("D:/FTP/SFTPUpload") as root folder getting error.

Is any one there who can provide me the solution for this.....??

Regards,

Deepak Jaiswal
Noida, India
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trying to upload a file through jscape sftp API in java and not able to set the default directory
 
Similar Threads
File Upload Error - Using JSCH/SFTP
can not read file
SFTP in Java
How do I read a file saved on a SFTP server using jScape's SFTP Api
how to read a text file within remote ftp directory