You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLS preemptive threaded upload
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
DoUpload
End EventHandler
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
if d<>nil then
if ProgressWindow.bar.Value<>d.currentprogress then
ProgressWindow.bar.Value=d.currentprogress
end if
if d.message<>"" then
ListBox1.AddRow d.message
d.message = ""
end if
if t.done then
// do not do some things in a thread
ProgressWindow.close
window1.listbox1.addrow "Result: "+str(t.error)
d = nil
Return
end if
end if
End EventHandler
End Control
Private Sub DoUpload()
Dim f As FolderItem
f=GetOpenFolderItem("all")
if f=nil then Return
d=new UploadCURL
d.OptionURL=url.text
d.OptionUpload=True
d.OptionUsername = "test"
d.OptionPassword = "password"
Break // change credentials
' Plugin does this for you
'd.OptionInFileSize = f.Length
if d.OpenMTInputFile(f) then
ProgressWindow.file.text=f.DisplayName
ProgressWindow.show
t = new UploadThread
t.d = d
t.run
else
MsgBox "Failed to open file."
end if
End Sub
Property Private d As UploadCURL
Property Private t As UploadThread
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
End Class
Class UploadCURL Inherits CURLSMBS
EventHandler Function Progress(dltotal as Int64, dlnow as Int64, ultotal as Int64, ulnow as Int64, percent as double) As boolean
dim s as string
if ultotal=0 then
s="Uploading..."
else
dim d as Double = ulnow/ultotal
currentprogress = 100*d
s="Uploading "+Format(d,"-0%")+" "+Format(ulnow/1024.0,"0")+" of "+format(ultotal/1024.0,"0")+" KB"
end if
message = s
End EventHandler
Property currentprogress As Integer
Property message As string
End Class
Class ProgressWindow Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control bar Inherits ProgressBar
ControlInstance bar Inherits ProgressBar
End Control
Control file Inherits Label
ControlInstance file Inherits Label
End Control
Control status Inherits Label
ControlInstance status Inherits Label
End Control
End Class
Class UploadThread Inherits Thread
EventHandler Sub Run()
error = d.PerformMT
done = true
End EventHandler
Property d As UploadCURL
Property done As Boolean
Property error As Integer
End Class