Hi,
sometimes it works, sometimes not. I download a file with about 1 mb. Sometimes the download works, sometimes the file size is only 2 bytes, sometimes the file does not even exist.
What am I doing wrong?
Thank you.
sometimes it works, sometimes not. I download a file with about 1 mb. Sometimes the download works, sometimes the file size is only 2 bytes, sometimes the file does not even exist.
What am I doing wrong?
Thank you.
B4X:
Sub Globals
Dim jobdnld As HttpJob
End Sub
Sub Activity_Create(FirstTime As Boolean)
Basis.FreezeOrientation
jobdnld.Initialize ("dnld",Me)
s=Main.hostname & "uploads/" & fname
DoEvents
jobdnld.Download (s)
DoEvents
End Sub
Sub JobDone (job As HttpJob)
Dim t As String
If job.Success = True Then
Select job.JobName
Case "dnld":
Dim out As OutputStream = File.OpenOutput(Main.outdir, fname, False)
File.Copy2(job.GetInputStream, out)
out.Close '<------ very important
Log (File.Size (Main.outdir,fname))
DoEvents
End Select
Else
Msgbox (job.ErrorMessage,fname)
Dim s As String
s=job.JobName & " " & job.ErrorMessage & " " & fname
Main.prot.Add ("Download " & s)
Activity.Finish
End If
End Sub