Android Question HTTP File Download Resume

biometrics

Active Member
Licensed User
Longtime User
Our product downloads large media files. For a long time we've been using FTP but it's causing issues and we want to switch to HTTP. The biggest concern is resumes of partial downloads. Which B4X HTTP library will allow resumes of partial downloads?
 

biometrics

Active Member
Licensed User
Longtime User
I'm looking into this now and I'm a bit confused by the changes.

I gather that the http libraries are being replaced (http -> okhttp and httputils -> okhttputils).

In this thread it seems you included the source for the libraries (https://www.b4x.com/android/forum/threads/okhttp-replaces-the-http-library.54723). Do I need to use them or is the libraries in B4A 6.8 the latest.

I'm looking into large downloads (will get to the resume next) with a progress bar and found this thread (https://www.b4x.com/android/forum/threads/download-huge-files-with-httputils2.30220). Do I need the source files httpjob and httputils2service or is the latest libraries in 6.8 the replacement?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Do I need to use them
you need to use the source from that post.
The Lib itself is uptodate in B4A.

But you need to change the source. Use the two source modules instead the compiled library in your app then (after you changed the source).
 
Upvote 0

biometrics

Active Member
Licensed User
Longtime User
Thanks for the reply Manfred but I'm still confused. Let's start at the beginning ...

I want download large files over HTTP and need to be able to resume partial downloads. Erel has said I need to use OkHttpUtils2 and the "range header" in the download request.

But before I do the resume I want to get the code to do a large download with a progress bar.

I have a basic download going as follows (the OkHttpUtils2 v2.4 is loaded):

B4X:
Sub Process_Globals
   Dim libHttpJob As HttpJob
End Sub

Sub Activity_Create(FirstTime As Boolean)
   libHttpJob.Initialize("Download", Me)
   libHttpJob.Download("https://xxxxxxxxxxxxxxxxxxxx")
End Sub

Sub JobDone (Job As HttpJob)
   Dim libHttpJob As HttpJob
   
   If Job.Success = True Then
     Select Case Job.JobName
     Case "Download"
         Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "1624.mp4", False)
         File.Copy2(Job.GetInputStream, out)
         out.Close
     End Select
   Else
     Log("Error: " & Job.ErrorMessage)
   End If
   Job.Release
End Sub

That works but next I want to do a progress bar. How would I do that?
 
Upvote 0
Top