I get problems with uploading a file by SFTP and I looked for information the problem is that when wanting to upload an image to SFTP I upload the name of the image with 0 KB I would like to know what happens with FTP I upload it and I added the corresponding certificates. With WinSCP I have no problems I would appreciate the help.
FTPSClient ftpClient = new FTPSClient(false);
try {
Log.i("chama",NameOfFile);
ftpClient.connect(url);
ftpClient.login(us, pass);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
ftpClient.execPBSZ(0);
ftpClient.execPROT("P");
// Run the passive mode command now instead of after loggin in.
File localFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + NameOfFolder + "/" + NameOfFile);
InputStream inputStream = new FileInputStream(localFile);
ftpClient.storeFile(NameOfFile , inputStream);
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
return false;
} catch (NetworkOnMainThreadException ex) {
return false;
}
return false;
}