Hi
I have IDs in excel file. then with those IDs I make download request with same url. yes it is image.
I put in loop n it worked well in few request.
The problem is that the more requests in a loop (sometimes it can be 1000 req in a time), the more images fail to download successfully. despite jobdone is success.
I tried using sleep but it didn't work.
I tried to put all in a sub, but also didn't work. some images saved, some empty (0) then saved again n empty again. not stable
what's the best trick? I mean how to make it stable and all requests successful (image not empty)
does this have anything to do with memory usage? or cookie?
Thank You
I have IDs in excel file. then with those IDs I make download request with same url. yes it is image.
req in loop:
For aloop=2 To reader.BottomRight.Row0Based+1
Dim Ids As String = reader.Get(XL.AddressOne("B",aloop))
downloadImageEvi(Ids)
Sleep(IIf(chkSlow.Checked,100,0))
prog2=(aloop-2)/xCount * 100
ProgressBar2.Progress=(aloop-2)/xCount
lblProgEvidence.Text="Requesting photo.... " & prog2 & "%"
Next
B4X:
Private Sub downloadImageEvi (IDs As String)
Try
Dim jobFoto As HttpJob
jobFoto.Initialize(IDs, Me)
jobFoto.Download(UrlD & IDs)
jobFoto.GetRequest.Timeout=60000
jobFoto.GetRequest.SetHeader("cookie",cookie)
jobFoto.GetRequest.SetHeader("User-Agent","Mozilla/5.0 (Windows NT 6.3; WOW64)")
' jobFoto.getrequest.setheader("Cache-Control","no-cache")
' jobFoto.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0")
Sleep(50)
Wait For (jobFoto) JobDone (jobFoto As HttpJob)
If jobFoto.Success Then
Dim bmp As B4XBitmap = jobFoto.GetBitmap
If bmp.Height=0 Then
Log("0?")
ClearCookies
Sleep(1000)
Else
Dim Out As OutputStream
Out = File.OpenOutput(folderTemp, IDs, False)
bmp.WriteToStream(Out, 60, "JPEG")
Out.Close
End If
bmp=Null
Else
Log(jobFoto.ErrorMessage)
End If
Catch
Log(LastException.Message)
End Try
' Log("release")
jobFoto.Release
End Sub
I put in loop n it worked well in few request.
The problem is that the more requests in a loop (sometimes it can be 1000 req in a time), the more images fail to download successfully. despite jobdone is success.
I tried using sleep but it didn't work.
I tried to put all in a sub, but also didn't work. some images saved, some empty (0) then saved again n empty again. not stable
what's the best trick? I mean how to make it stable and all requests successful (image not empty)
does this have anything to do with memory usage? or cookie?
Thank You