Postfile ProgressBar

alexposta2

Member
Licensed User
Longtime User
Hi,
does anyone know how to create a progressbar for httputils.postfile?
I've tried many method without success.

thank you for support.
Alessio
 

alexposta2

Member
Licensed User
Longtime User
Hi Erel,
Thank you for your reply.
Can you link me the post # how to discuss about progress?
I've searched all post without success.

thank you
Alessio

update:
I've found post about progress http://www.b4x.com/forum/71551-post92.html.
Unfortunately this is about download.
I woul'd like to say if is possibile to chek upload file.

thank you
Alessio
 
Last edited:
Upvote 0

alexposta2

Member
Licensed User
Longtime User
thanks to erel sample i've solved my issue.
I've modified the httputilsservice:

B4X:
Dim cout As CountingInputStream

B4X:
If cout.IsInitialized Then cout.Close
cout.Initialize(PostInputStream)
req.InitializePost(link, cout, PostLength)

thank you
Alessio
 
Upvote 0

ziomorgan

Active Member
Licensed User
Longtime User
Hi Alessio,
i'm going crazy with progressbar upload.
Would you be so kind to give me further details about this?
thanks
:BangHead:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If you are using HttpUtils2 then you should modify HttpJob.PostFile:
B4X:
Public Sub PostFile(Link As String, Dir As String, FileName As String)
   Dim length As Int
   If Dir = File.DirAssets Then
      Log("Cannot send files from the assets folder.")
      Return
   End If
   length = File.Size(Dir, FileName)
   Dim In As InputStream = File.OpenInput(Dir, FileName)
   cin.Initialize(In)
   req.InitializePost(Link, cin, length)
   CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)   
End Sub
cin is a global variable of type CountingInputStream. You should use a timer to check cin.Count and report the progress.
 
Upvote 0

korn

Member
Licensed User
Longtime User

erel, above solution is not working in jellybean, kitkat. cin.Count is zero initially then becomes total size of file. however upload is still in progress. does anyone have similar problem ?
 
Upvote 0

korn

Member
Licensed User
Longtime User
Try to send a large file and see whether the process is tracked. It is possible that it reads the complete file to an internal buffer.
yes upload progress works for larger file. buffer was reading complete file at once for smaller files. however for large file also, at end part of upload when progress is 100% but in actual last block of buffer is still uploading.

is it possible to change buffer size or any other workaround for this. like count data sent over http rather than file input buffer read completed size.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…