Sub DownloadFile(Link As String, FileName As String) As ResumableSub
Dim job As HttpJob
job.Initialize(FileName, Me) 'note that the name parameter is no longer needed.
job.Download(Link)
Wait For (job) JobDone(job As HttpJob)
If job.Success Then
'save the file
Try
Dim OutStream As OutputStream
OutStream = File.OpenOutput(File.DirApp, "Videos/" & FileName, False)
File.Copy2(job.GetInputStream,OutStream)
OutStream.Close
Catch
LogError($"DownloadFile: ${FileName} - ${LastException}"$)
End Try
Else
LogError($"DownloadFile: ${Link}. ${job.ErrorMessage}"$)
End If
job.Release
Return job.success
End Sub