Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/FTP/CURLS ftp file upload with progress


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/FTP/CURLS ftp file upload with progress

This example is the version from Tue, 16th Sep 2019.

Project "CURLS ftp file upload with progress.xojo_binary_project"
FileTypes
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
Private Sub DoUpload() dim f as FolderItem dim e as integer dim d as UploadCURL dim b as BinaryStream f=GetOpenFolderItem("all") if f=nil then Return b = BinaryStream.Open(f) d=new UploadCURL d.stream=b d.OptionURL=url.text d.OptionUpload=true d.OptionInFileSize=b.Length d.OptionUsername = "test" d.OptionPassword = "xxxx" ProgressWindow.file.text=f.DisplayName ProgressWindow.show e=d.Perform ProgressWindow.close listbox1.addrow "Result: "+str(e) End Sub
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 dim p as integer = 100*d if ProgressWindow.bar.Value<>p then ProgressWindow.bar.Value=p ProgressWindow.bar.Refresh end if s="Uploading "+Format(d,"-0%")+" "+Format(ulnow/1024.0,"0")+" of "+format(ultotal/1024.0,"0")+" KB" end if if s<>ProgressWindow.status.text then ProgressWindow.status.text=s ProgressWindow.status.Refresh end if window1.listbox1.addrow s window1.listbox1.Refresh End EventHandler
EventHandler Function Read(count as integer) As string Return stream.Read(count) End EventHandler
EventHandler Function RestartRead() As boolean stream.position=0 Return false // no error End EventHandler
Property stream As binaryStream
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
End Project

See also:

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


The biggest plugin in space...