FTP Progress bar example

cymorg

Member
Licensed User
Longtime User
Anyone got an example of how to use a ProgressBar with FTP upload?

Please don't just link back to Erel's example as it is not clear enough to me.

Still loving B4A.

:sign0163: Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Sub Process_Globals
   Dim FTP As FTP
   Dim currentFileSize As Int
End Sub
Sub Globals
   Dim pb As ProgressBar
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      FTP.Initialize("FTP", "xxx.xxx.xxx.xxx", 21, "username", "password")
   End If
   pb.Initialize("")
   Activity.AddView(pb, 0, 0, 100%x, 30dip)
   
   currentFileSize = File.Size(File.DirRootExternal, "1.mp4")
   FTP.UploadFile(File.DirRootExternal, "1.mp4", False, "/1.mp4")
End Sub

Sub FTP_UploadCompleted (ServerPath As String, Success As Boolean)
   If Success Then pb.Progress = 100
End Sub

Sub FTP_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
   Log(TotalUploaded & " " & Total)
   pb.Progress = 100 * TotalUploaded / currentFileSize
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…