Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/CURLS preemptive threaded upload
Required plugins for this example: MBS CURL Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/CURLS preemptive threaded upload
This example is the version from Sat, 25th Apr 2014.
Project "CURLS preemptive threaded upload.rbp"
Filetype text
Filetype all
End FileTypes
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 ' 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 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 UploadCURL Inherits CURLSMBS
EventHandler Function Progress(dltotal as double, dlnow as double, ultotal as double, ulnow 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
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS CURL Plugin.

MBS FileMaker blog