on 10-10-2012 11:36 AM
Hi All,
We have a requirement, where in, the business user could read /write PDF and excel files respectively to particular locations in the SFTP server.
I have gone through many links but am not getting any thing close to the requirement.
Challenges what I see:
1) It is a SFTP server and just not a FTP server.
2) It is a remote machine.
Solutions which I have thought of:
1) Using respository manager in KM to read/write data in remote server (SFTP server in our case)
2) Have got links like http://www.ajaxapp.com/2009/02/21/a-simple-java-ftp-connection-file-download-and-upload/ which talks about
how to write a Java program to connect to FTP.
Honestly, I have not tried this in my machine and so not sure how it will perform, that too on SFTP server.
So, request you all here, to let me know how to deal with this requirement, that will not make the application development complex.
Let me know if any body wants additional information or have questions.
Regards
DK
Hi DK,
You can use JSch API which is widely used for connecting a SFTP thru Java.
http://epaul.github.io/jsch-documentation/simple.javadoc/com/jcraft/jsch/package-summary.html
below is a sample code to connect and read file from an SFTP server -
import com.jcraft.jsch.*;
public class TestJSch {
public static void main(String args[]) {
JSch jsch = new JSch();
Session session = null;
try {
session = jsch.getSession("username", "127.0.0.1", 22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword("password");
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.get("remotefile.txt", "localfile.txt");
sftpChannel.exit();
session.disconnect();
} catch (JSchException e) {
e.printStackTrace();
} catch (SftpException e) {
e.printStackTrace();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello All,
Looking forward to all of you for some related information to proceed with the requirement.
Regards
DK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.