This code reads the date of a remote file :
Unfortunately you must first download the entire download.
It can be very slow in the case of large files.
Is there a way to download only the first 100 bytes (for example) of the file (where is the header being stored, I suppose) ?
Thanks in advance.
B4X:
Sub hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Dim cs As CountingOutputStream
cs.Initialize(File.OpenOutput(TempFolder, TaskId, False))
Dim j As HttpJob = TaskIdToJob.Get(TaskId)
Dim jt As JobTag = j.Tag
jt.CountingStream = cs
jt.Total = Response.ContentLength
If jt.Data.url = "" Then
Log("Job cancelled before downloaded started")
cs.Close
End If
Response.GetAsynchronously("response", cs , True, TaskId)
'---
Dim Headers As Map=Response.GetHeaders
Dim i As Int
Dim Key, Value As String
For i=0 To Headers.Size-1
Key=Headers.GetKeyAt(i)
if Key="last-modified" Then
value=Headers.GetValueAt(i)
If Response.ContentType="image/jpeg" Then
'*****************
strRemoteData=Value.Trim
'*****************
End If
End If
Next
End Sub
Unfortunately you must first download the entire download.
It can be very slow in the case of large files.
Is there a way to download only the first 100 bytes (for example) of the file (where is the header being stored, I suppose) ?
Thanks in advance.