-1

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;
    }
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Chama
  • 1
  • FTPS is not SFTP + Post WinSCP log file. + Do you have an access to server-side log? – Martin Prikryl May 01 '18 at 09:36
  • if you have access to the ftps server with another ftps application it does everything normal and from android just upload the name of the file – Chama May 01 '18 at 14:15
  • Post a log showing that. – Martin Prikryl May 02 '18 at 06:20
  • Solution All the code was fine was a configuration of the ftp was missing add these two lines in the configuration file vsftpd.conf require_ssl_reuse = NO ssl_ciphers = HIGH – Chama May 02 '18 at 14:21
  • Possible duplicate of [How to connect to FTPS server with data connection using same TLS session?](https://stackoverflow.com/questions/32398754/how-to-connect-to-ftps-server-with-data-connection-using-same-tls-session) – Martin Prikryl May 02 '18 at 14:23

1 Answers1

0

Solution All the code was fine was a configuration of the ftp was missing add these two lines in the configuration file vsftpd.conf require_ssl_reuse = NO ssl_ciphers = HIGH

Chama
  • 1
  • That's a workaround, not a solution. SSL session reuse is a useful feature that you should not disable. See the question, I've linked above. – Martin Prikryl May 02 '18 at 14:24