You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLS simple file download
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
DoDownload url.text, SpecialFolder.Desktop.Child("test.jpg")
End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
End Control
Private Sub DoDownload(URL as string, dest as FolderItem)
dim e as integer
dim d as DownloadCURL
dim b as BinaryStream = BinaryStream.Create(dest, true) // needs to be BinaryStream.Create(dest) in newer RB versions
d=new DownloadCURL
d.b = b
d.OptionURL = URL
e=d.Perform
b.Close
Canvas1.Backdrop = picture.Open(dest)
ResultText.text="Result: "+str(e)
End Sub
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
Class DownloadCURL Inherits CURLSMBS
EventHandler Function Progress(dltotal as Int64, dlnow as Int64, ultotal as Int64, ulnow as Int64) As boolean
if dltotal=0 then
window1.ResultText.text="Downloading..."
else
window1.ResultText.text="Downloading "+Format(dlnow/dltotal,"0%")
end if
Return false
End EventHandler
EventHandler Function Write(data as string, dataSize as Integer) As integer
b.write data
Return lenb(Data)
End EventHandler
Property b As BinaryStream
End Class