I have a problem with uploading a file to my ftp server: The problem is not that the file does not upload, or that I can not connect to the FTP server (in my local network) ... The problem is that after connecting, upload the file, the connection to the server (from the user created) does not close ... The problem is in uploading the file, since if I do not upload anything (just me "logeo" and "deslogueo" ) everything is fine. I notice that it never reaches the%% share block, unless the user is manually disconnected from the server. In conclusion the problem is that it uploads the file, but it stays stuck there and never leaves the connection. Any ideas to solve this problem?
I leave the code
private class subirFTP extends AsyncTask<Void ,Void,Void>
{
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
Toast msg = Toast.makeText(MainActivity.this,"El programa va a subir el fichero",Toast.LENGTH_LONG);
msg.show();
}
Toast msg;
@Override
protected Void doInBackground(Void ... params) {
FTPClient conftp = new FTPClient();
try {
conftp.connect(InetAddress.getByName("192.168.1.102"));
conftp.login("usurio","clave");
//conftp.changeWorkingDirectory("/carpeta");
conftp.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
conftp.setFileType(FTP.BINARY_FILE_TYPE);
BufferedInputStream buffer = new BufferedInputStream(new FileInputStream("/storage/extSdCard/texto.txt"));//Ruta del archivo para enviar
conftp.enterLocalPassiveMode();
conftp.storeFile("texto.txt",buffer);
conftp.enterLocalActiveMode();
buffer.close();
}
catch (IOException a )
{
}
finally {
try{
conftp.logout();
conftp.disconnect();
}
catch (Exception e){
}
}
return null;
}
}