【问题标题】:Java code for connect alfresco through ftps connection通过 ftps 连接连接 alfresco 的 Java 代码
【发布时间】:2014-08-22 09:20:10
【问题描述】:

当我尝试通过 SFTP 连接我们的 alfresco 时,它无法连接 alfresco。它挂起资源管理器,并且记录器文件中也没有错误。

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();

}

我只在我们的控制台中得到了输出 1 在执行 ftp.connect("172.17.178.144",2121);这个代码系统将被挂起,在我们的控制台中没有错误

我可以使用 Filezila FTP 客户端软件通过 SFTP 连接到我的 Alfresco。谁能帮我解决这个问题?

【问题讨论】:

    标签: java alfresco ftp-client ftps


    【解决方案1】:

    如果我没记错的话,Alfresco 选择了 FTPS。

    所以在这里用下面的代码试试吧:http://alvinalexander.com/java/jwarehouse/commons-net-2.2/src/main/java/examples/ftp/FTPSExample.java.shtml

    【讨论】:

    • 感谢您分享代码,但是当我执行此代码时,出现错误无法连接到服务器 org.apache.commons.net.ftp.FTPConnectionClosedException:连接已关闭且没有指示。你能帮我为什么我得到这个错误我的代码如下
    • 您是否先尝试过不使用 FTPSClient 而仅使用 FTP Client?
    • 是的,我可以通过 ftps 将我们的服务器与 filezila ftp 客户端连接起来。并且从 java 代码 alos 我可以通过 ftp 连接我们的服务器
    猜你喜欢
    • 2023-03-16
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 2015-07-16
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 2011-09-26
    相关资源
    最近更新 更多