3

我正在尝试使用 Apache 公共库在 android 中实现 FTP 文件上传。通信必须通过显式 TLS 身份验证来完成。我可以登录,连接到服务器并成功列出文件,但是当我尝试将文件存储到服务器时,它会在服务器的目标文件夹中创建一个大小为 0 的文件并抛出 SSLException: Write error, broken pipe。如何克服这一点?下面是我的代码:

FTPSClient ftpClient = new FTPSClient("TLS", false);
ftpClient.addProtocolCommandListener(new PrintCommandListener(new   
KeyManagerFactory kmf =            getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(null, null);
KeyManager km = kmf.getKeyManagers()[0];
ftpClient.setKeyManager(km);
ftpClient.setBufferSize(1000);
ftpClient.setConnectTimeout(5000);
ftpClient.connect(InetAddress.getByName("server ip address"), 990);
// Set protection buffer size
ftpClient.execPBSZ(0);
// // Set data channel protection to private
ftpClient.execPROT("P");
ftpClient.login("username", "password");
ftpClient.changeWorkingDirectory("/");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
buffInp = new BufferedInputStream(new     FileInputStream(file.getAbsolutePath()));

//throwing exception here
boolean status = ftpClient.storeFile( picture.getName(), buffInp );
4

0 回答 0