NET library ftp upload/download

Rusty

Well-Known Member
Licensed User
Longtime User
I have begun using the NET library to conduct FTP communications to upload and download files to my website folders.

When I connect to my tablet with B4A_Bridge and compile and execute the following code:
B4X:
'Activity module
Sub Process_Globals
    Dim FTP As FTP
End Sub
Sub Globals
    Dim btnDownload As Button
    Dim btnUpload As Button
    Dim btnClose As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        Activity.LoadLayout("Main")
        FTP.Initialize("FTP", "ftp.xxxx.com", 21, "iiii", "pppp")     
    End If
End Sub
Sub btnDownload_Click
    FTP.DownloadFile("/dddd/filename.txt", False, File.DirRootExternal, "DELETETHIS.txt")
End Sub
Sub btnUpload_Click
    FTP.UploadFile(File.DirRootExternal, "b4a_bridge.apk", False, "/dddd/DELETETHIS.apk")
End Sub
Sub FTP_DownloadProgress (ServerPath As String, TotalDownloaded As Long, Total As Long)
    Dim s As String
    s = "Downloaded " & Round(TotalDownloaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub
Sub FTP_DownloadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub
Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
    Dim s As String
    s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
    If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
    Log(s)
End Sub
Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
    Log(ServerPath & ", Success=" & Success)
    If Success = False Then Log(LastException.Message)
End Sub
Sub FTP_ListCompleted (ServerPath As String, Success As Boolean, Folders() As FTPEntry, Files() As FTPEntry)
 Log(ServerPath)
    If Success = False Then
        Log(LastException)
    Else
        For i = 0 To Folders.Length - 1
            Log(Folders(i).Name)
        Next
        For i = 0 To Files.Length - 1
            Log(Files(i).Name & ", " & Files(i).Size & ", " & DateTime.Date(Files(i).Timestamp))
        Next
    End If
End Sub
Sub btnClose_Click
    FTP.Close    
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
I click the btnDownload and it creates the file on the dirrootexternal location but it is empty. There is no status update and no download complete.

I click the btnUpload and nothing happens at all.

I've viewed the unfiltered logs and the only thing that shows when a button is touched is:
B4X:
void cb_onMotion(uint16_t)
GC_CONCURRENT freed 141K, 4% free 6802K/7047K, paused 3ms+2ms
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41339d48
Triggered Alarm 417d7720 RTC_WAKEUP IntentSender{417574a8: PendingIntentRecord{417fb768 com.android.vending startService}}
GC_CONCURRENT freed 594K, 10% free 7265K/8007K, paused 2ms+2ms
[1] 5.onFinished: Installation state replication succeeded.
GC_CONCURRENT freed 206K, 7% free 7479K/8007K, paused 2ms+2ms
Really, this is all that is in the unfiltered logs...
Any ideas what might be wrong?
WiFi is on, is connected (obviously b4a_bridge is running), I'm able to browse the net; http transfers work, but this ftp test code won't do anything.
Thanks,
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
I'm not sure what you are asking.
I am trying to connect to my website FTP site from my Android tablet.
Can you clarify?
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
I downloaded AndFTP and it works great.
The code above used to work. It (or a derivative) has been in the field for over 2 years.
Any ideas? Can you provide an APK of the above code or your sample code that I can try?
Thanks,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
My ISP just doubled my connection speed for some reason. It required me to power down and re-power my modem and router (to update firmware, I assume).
AndFTP is able to work just fine, but the code above still won't work. I "forgot" all the networks except for one, still no happiness.
Any ideas what might interfere with the above code but still AndFTP is able to work?
Thanks very much for your attention on this.
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
I just got your other email on Passive mode.
I tried it and now I can connect, download and upload.
What might have changed? I've never had to use passive mode.
Also, forgive my ignorance, but what is the difference between Active and Passive modes?
Thanks!
Rusty
 
Upvote 0
Top