Android Question Know remote file size

Diego Roman

Member
Licensed User
Hi. I need to know the size of an internet file before downloading it. Does anyone know how to obtain that file size?
Thanks in advance.
 

Erel

Administrator
Staff member
Licensed User
Does anyone know how to obtain that file size?
I know:
B4X:
Sub Test
   Dim j As HttpJob
   j.Initialize("", Me)
   j.Head("https://b4x-4c17.kxcdn.com/android/forum/data/avatars/m/104/104201.jpg?1491188256")
   Wait For (j) JobDone (j As HttpJob)
   If j.Success Then
       Dim length As List = j.Response.GetHeaders.GetDefault("content-length", Null)
       If length.IsInitialized  Then
           Log($"File size: ${length.Get(0)}"$)
       End If
   End If
End Sub
 
Top