'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
End Sub
Sub AppStart (Args() As String)
DownloadImage("https://picsum.photos/200/300")
StartMessageLoop
End Sub
Private Sub DownloadImage (Url As String)
Try
Log("Start download...")
Dim j As HttpJob
j.Initialize("", Me)
j.Download(Url)
Wait For (j) JobDone (j As HttpJob)
If j.Success Then
Dim out As OutputStream = File.OpenOutput(File.DirApp, "Test.jpeg", False)
Dim tmp As InputStream = j.GetInputStream
File.Copy2(tmp, out)
out.Close
Log("File saved!")
'Dim scaler As ImageScaler
'scaler.Initialize
'scaler.FileType = "JPEG"
'If scaler.ResizeImage(File.DirApp, File.DirApp, "Test.jpeg", 200, 200, "FIT_EXACT") Then
' Log("File resized!")
'Else
' Log(scaler.Error)
'End If
'
'Dim SU As StringUtils
'Dim buffer() As Byte = File.ReadBytes(File.DirApp, scaler.ResizedFileName)
'Dim encoded As String = SU.EncodeBase64(buffer)
'Log(encoded)
Else
Log(j.ErrorMessage)
End If
Catch
Log(LastException.Message)
End Try
j.Release
End Sub