【问题标题】:FTPSClient, What values to give for Remote and LocalFTPSClient,为远程和本地提供什么值
【发布时间】:2019-08-25 19:43:15
【问题描述】:

我是 FTPSClient 的新手,我试图连接到在我的笔记本电脑中创建的 FTPS。我不知道某些方法的工作原理及其参数含义。 例如, 在我的代码中,我创建了一个 FTPSClient,如下所示:

FTPSClient ftps =new FTPSClient();

然后使用带有 IP 地址的 connect() 方法连接到服务器。

ftps.connect("172.xx.xx.xxx");

在每一步之后,我都会检查回复代码。

ftps.getReplyCode();

在下面的代码中我知道 用户名 = 系统用户名 password = 登录密码

ftps.login(username, password);

在 Internet 信息服务 (IIS) 中的我的系统中。使用 ssl 创建了一个 ftp 服务器,并提供了以下目录进行共享。

C:\Users\karan-pt2843\Desktop\FTPS

想将下面目录中的文件发送到服务器。

D:\sam.txt

现在我想在上面给定的目录中的服务器中存储一个文件,我尝试使用

remote="";
local="";
InputStream input;
input = new FileInputStream(local);
ftps.storeFile(remote, input);
input.close();

我不知道为远程和本地赋予什么价值。请帮助我了解赋予它们的价值观以及内部发生的事情。

【问题讨论】:

标签: java ftps


【解决方案1】:
    // Use passive mode as default because most of us are
    // behind firewalls these days.
    ftps.enterLocalPassiveMode();
    ...
    String remote = "samFromClient.txt"; //Place on FTP
    String input = "D:/sam.txt"          //Place on your Client
    //Your FTP reads from the inputstream and store the file on remote-path
    InputStream input = new InputStream(new FileInputStream(input));
    ftps.storeFile(remote, input);
    input.close();
    ftps.logout();
    ...

取自:Apache example

【讨论】:

  • 感谢连接成功。但它显示不同的错误。
  • ftps.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); 添加这一行,你的控制台上应该会有更多的输出。哪个错误?
  • 'FTPSs 220 Microsoft FTP Service AUTH TLS 234 AUTH 命令正常。期待 TLS 协商。连接到 172.24.100.113。用户 karan-pt2843 331 需要密码 PASS Nivedhaav@1 230 用户登录。SYST 215 Windows_NT 远程系统是 Windows_NT PASV 227 进入被动模式 (172,24,100,113,214,42)。 STOR samFromClient.txt 534-策略需要 SSL。 Win32 错误:访问被拒绝。错误详情:SSL 政策要求 SSL 用于数据通道。 534 结束退出 221 再见。'
  • String protocol = "SSL"; // SSL/TLS 并在构造函数中。 ftps = new FTPSClient(protocol);
  • 我在登录c.setFileType(FTP.BINARY_FILE_TYPE); c.execPBSZ(0); // Set protection buffer size c.execPROT("P"); // Set data channel protection to private c.enterLocalPassiveMode();后添加了这段代码谢谢你的帮助。
猜你喜欢
  • 2013-05-17
  • 1970-01-01
  • 2015-07-12
  • 1970-01-01
  • 2020-09-17
  • 2018-06-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多