Android Question postmultipart progress bar

JnSklikas

Member
Hallo my friends.
I am using an HttpJob to upload a zip file.
The code I am using is


Dim j As HttpJob
j.Initialize("j", Me)
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "filetoupload"
fd.Dir = Starter.DBFileDir
fd.FileName ="photo1.zip"
fd.ContentType = "Application/zip"
Wait For (CheckConnected) Complete (Connected As Boolean)
If Connected Then
j.PostMultipart("http://185.234.52.224/upload/ydor_oixalia", CreateMap("param1": "value1"), Array(fd))
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Lmessage.Text = "H Μεταφορά του zip έγινε !!!"
Else
Lmessage.Text ="***Error: " & j.ErrorMessage
ToastMessageShow("Error: " & j.ErrorMessage, True)
End If
j.Release
End If



Since the zip file can grow very large, I want to add a progress bar to show the user the percentage of the file that has been uploaded

Thank you
 

JnSklikas

Member
Hi Erel

Sorry I forgot

B4X:
Dim j As HttpJob
j.Initialize("j", Me)
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "filetoupload"
fd.Dir = Starter.DBFileDir
fd.FileName ="photo1.zip"
fd.ContentType = "Application/zip"
Wait For (CheckConnected) Complete (Connected As Boolean)
If Connected Then
j.PostMultipart("http://185.234.52.224/upload/ydor_oixalia", CreateMap("param1": "value1"), Array(fd))
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Lmessage.Text = "H Μεταφορά του zip έγινε !!!"
Else
Lmessage.Text ="***Error: " & j.ErrorMessage
ToastMessageShow("Error: " & j.ErrorMessage, True)
End If
j.Release
End If
 
Upvote 0

JnSklikas

Member
Thank you Erel.
I just want to sow the user that the failure was due to bad connection.
This check does not take any time.
The part that I want to monitor is the
j.PostMultipart
Is there a way to do that

Ps B4A is great. Specially for old programmers like my self
 
Upvote 0

JnSklikas

Member
Hi Erel,

Yesterday (27/4/2021) you posted a project that answers this issue
I have download the code and implemenetd it in my solution
It works great
I cannot find the link to attach it to this post for future refference

Anyway thank you very much for this briliant solution
 
Upvote 0
Top