How to write a txt file to an explicit FTP TLS with Delphi 10.3 on Android?

159 views Asked by At

I have this code that works perfectly on Windows, but when running the application on Android, the connection to FTP is successful, but when writing the file, the app stays paused without doing anything.

It should be noted that on the FTP server, it appears that I am loading the file as in the image:

image

This is my code:

procedure TForm1.Button1Click(Sender: TObject);
begin
//  testClever;
//  exit;

    IdFTP:=TIdFTP.Create(nil);
    IdSSLIO:=TIdSSLIOHandlerSocketOpenSSL.Create(nil);
      IdFTP.Disconnect();
        {$ifdef mswindows}
          idopensslsetlibpath('C:\Users\karol.campos\Desktop\FTPSExample\SSL');
        {$endif}
        {$ifdef android}
          idopensslsetlibpath(TPath.GetDocumentsPath);
        {$endif}
        IdSSLIO.SSLOptions.Method:=TIdSSLVersion.sslvSSLv23;
        IdSSLIO.PassThrough:=true;
        IdFTP.IOHandler:=IdSSLIO;
        IdFTP.ListenTimeout:=0;
        IdFTP.ReadTimeout:=0;
        IdFTP.TransferTimeout:=0;
        IdFTP.Passive:=true;
        IdFTP.UseTLS:=TIdUseTLS.utUseExplicitTLS;
        IdFTP.DataPortProtection:=TIdFTPDataPortSecurity.ftpdpsPrivate;

        IdFTP.Host := '(ip_ftp)';
        IdFTP.Username := '(user)';
        IdFTP.Password := '(pass)';
        
        try
        IdFTP.Connect;

        try
            {$ifdef mswindows}
              IdFTP.Put('D:\SeLogro.txt','SeLogro.txt',false);
            {$endif}
            {$ifdef android}
              IdFTP.Put('storage/emulated/0/SeLogro.txt','SeLogro.txt',false);
            {$endif}
              ShowMessage('Ready!');
            finally
              IdFTP.Disconnect();

            end;
        except
        on E : Exception do
         begin
           ShowMessage('Exception class name = '+E.ClassName);
           ShowMessage('Exception message = '+E.Message);
         end;
        end;
end;

I found a similar question, but the code is in Java, will it be possible to do it in Delphi 10.3?

android ftp file tranfer over explicit TLS

0

There are 0 answers