FTP Error

pmsmc

Member
Licensed User
Longtime User
Hi,
I am rather new in this android dev. stuff, but have been a VB programmer since I remember.
I first want to congratulate the people responsible for the product, since in a blast !!! Very good to be able to program in Almost VB for the Android platform.
Well, having said that, let me focus on the problem at hand.
The FTP Library (I am using the new NET Library, but seems that it is the some)

When I try to Upload a file I always get an error, but no log info, just a False in the Uploadcomplete event.

The Log window doesn't show any activity other than the activity create, first time=true, etc.
What am I doing wrong ?
Thank in advance

B4X:
Sub Activity_Create(FirstTime As Boolean)
  activity.loadlayout("main")
  readCFG
  Lista.Initialize ("Lista")
  If FirstTime Then
      'FTP.Initialize("FTP", FTPSvr, 21, FTPUser, FTPPass)
      FTP.Initialize("FTP", "93.108.251.166", 21, "files", "Files4you")
       If FTP.IsInitialized Then
          FTPStatus="FTP Inicializado"
      End If
   End If
End Sub

B4X:
Sub b_testarcfg_Click
   If ExternalSD=True Then
      File.WriteString (File.DirRootExternal ,"test.ftp","FTP")
      l_statuscfg.Text ="Creating File"
      FTP.UploadFile (File.DirRootExternal ,"test.ftp",True,"/")
      l_statuscfg.Text ="Uploading File"
      FTP.DeleteFile ("/test.ftp")
      l_statuscfg.Text ="Deleting File"
   Else
      File.WriteString (File.DirInternal ,"test.ftp","FTP")
      l_statuscfg.Text ="Creating File"
      FTP.UploadFile (File.DirInternal ,"test.ftp",True,"/")
      l_statuscfg.Text ="Uploading File"
      FTP.DeleteFile ("/test.ftp")
      l_statuscfg.Text ="Deleting File"
    End If
End Sub

B4X:
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    If Success = True Then
      l_statuscfg.Text="Communication OK"
   Else
      l_statuscfg.Text="Communication ERROR"
   End If
End Sub
 

pmsmc

Member
Licensed User
Longtime User
I will implement the Log(LastException.Message) code
and will try to use some kind of delay beetween ftp blocks.
is there any way to do that ?
like a wait or sleep command ?
 
Upvote 0

pmsmc

Member
Licensed User
Longtime User
I tried everything.
Either i Get an invalid filename, or it doesn't show anything in the log windows
Even the simple code below doesn't work.
Please :sign0085:

B4X:
Sub Test
     File.WriteString (File.DirRootExternal ,"test.ftp","FTP")
     FTP.UploadFile (File.DirRootExternal ,"test.ftp",True,"/test.ftp")
End sub
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
FTP Errors

I tried everything.
Either i Get an invalid filename, or it doesn't show anything in the log windows
Even the simple code below doesn't work.
Please :sign0085:

Please see the code below. It has some checks in it that will help make sure the process works...

B4X:
Sub Test
     File.WriteString (File.DirRootExternal, "test.ftp", "FTP")
     '***This will make sure the file is written before it tries to upload it
     '***It will better to use a Timer if it is writting a large file
     Do While File.Exists (File.DirRootExternal, "test.ftp") = False
     Loop
     FTP.UploadFile (File.DirRootExternal, "test.ftp", True, "test.ftp")
End sub

Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
     Log("Uploaded: /" & ServerPath & ", Success=" & Success & "...")
     If Success = False Then 
          Log(LastException.Message)
     End If   
     '***Call a sub or command here to delete the file if you wish.  This way 
     '***you know your file is there to delete
     FTP.Close
End Sub


Thanks,

Margret
 
Upvote 0

pmsmc

Member
Licensed User
Longtime User
Well, I have tried everything.
I have attached the source file, so any kind soul that will be willing to lend a hand can check it.
when I press the Test Button in the Config screen it should create a file and upload it, but apparently it does nothing
:sign0085::sign0085::sign0085::sign0163:
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
FTP Issues

Well, I have tried everything.
I have attached the source file, so any kind soul that will be willing to lend a hand can check it.
when I press the Test Button in the Config screen it should create a file and upload it, but apparently it does nothing
:sign0085::sign0085::sign0085::sign0163:

Hello, I downloaded and ran your code. I get an error 530, invalid user or password, so I can't do any other testing. However, looking at the code I don't see where you are adding any results to the ListView. That should be done in FTP_ListCompleted. Something like: lista.AddSingleLine(Files(i)).

Hope this helps. Get me a valid login and I will look at it a little more.

Thanks,

Margret
 
Upvote 0

pmsmc

Member
Licensed User
Longtime User
My fault, Margaret,
you can try now, if you please.
I don't even see the bad password message in the log.
Maybe the sdk need reinstalling, since i've installed the full B4A over the trial version.
 
Upvote 0

pmsmc

Member
Licensed User
Longtime User
I have just remembered something.
I am testing the application in the AVD Machine.
I am not testing it in a real Android Machine. Can it be the reason for the FTP errors?
I have tried a simple program with just the FTP.Initialize and a download and I can't still see any output or errors in the Log Window.
:BangHead:
 
Upvote 0
Top