0

When I try to connect our alfresco through SFTP it is not able to connect alfresco. It hangs the explorer and no error goes in the logger file also.

public void FTPTest()throws SocketException, IOException, NoSuchAlgorithmException
{

    FTPSClient ftp = new FTPSClient("SSL");
    System.out.println("1");
    ftp.connect("172.17.178.144",2121); // or "localhost" in your case
    System.out.println("2"+ftp.getReplyString());

    System.out.println("login: "+ftp.login("admin", "admin"));
    System.out.println("3"+ ftp.getReplyString());
    ftp.changeWorkingDirectory("/alfresco");
    // list the files of the current directory
    FTPFile[] files = ftp.listFiles();
    System.out.println("Listed "+files.length+" files.");
    for(FTPFile file : files) {
        System.out.println(file.getName());
    }
    // lets pretend there is a JPEG image in the present folder that we want to copy to the desktop (on a windows machine)
    ftp.setFileType(FTPClient.BINARY_FILE_TYPE); // don't forget to change to binary mode! or you will have a scrambled image!
    FileOutputStream br = new FileOutputStream("C:\\Documents and Settings\\casonkl\\Desktop\\my_downloaded_image_new_name.jpg");

    ftp.retrieveFile("name_of_image_on_server.jpg", br);
    ftp.disconnect();

}

I got output in our console only 1 at the execution of ftp.connect("172.17.178.144",2121); this code system will be hang no error got in our console

I am able to connect to my Alfresco through SFTP with the Filezila FTP client software. Can any one help me resolve this issue?

dedunu
  • 172
  • 8

1 Answers1

0

If I'm not mistaken then Alfresco chose for FTPS.

So try it with the following code here: http://alvinalexander.com/java/jwarehouse/commons-net-2.2/src/main/java/examples/ftp/FTPSExample.java.shtml

Tahir Malik
  • 6,623
  • 15
  • 22
  • Thank u malik for sharing the code but when I m impleneting this code getting error could not connect to server org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication. can u help me why I m getting this error my code is following – chandan kumar Aug 25 '14 at 07:32
  • 1
    Have you tried it first without the FTPSClient and just FTP Client? – Tahir Malik Aug 25 '14 at 11:00
  • yes I m able to connect our server with filezila ftp client through ftps . and from java code alos I m able to connect our server through ftp any changes or setting need on server ya local machine for FTPS – chandan kumar Aug 25 '14 at 12:02