I am trying to implement a FTP file upload in android, using Apache commons library. The communication must be done through explicit TLS authentication. I can login, connect to server and list files successfully, but when i am trying to store a file to the server, it creates a file in the destination folder of the server with size 0 and throwing SSLException: Write error, broken pipe. How to overcome this? Below is my code:
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 );