Platforms to show: All Mac Windows Linux Cross-Platform

/CURL/Upload resume


Required plugins for this example: MBS CURL Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /CURL/Upload resume

This example is the version from Wed, 3rd Jan 2023.

Project "Upload resume.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class MainWindow Inherits Window
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() DoUpload false End EventHandler
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control DebugLog Inherits TextArea
ControlInstance DebugLog Inherits TextArea
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() DoUpload true End EventHandler
End Control
Private Sub DoUpload(firstTime as Boolean) dim file as FolderItem = app.file dim filesize as Int64 = file.Length dim e as integer dim d as UploadCURL d=new UploadCURL // this is the file content here: 'd.InputData = "Just a little bit text. Have fun!" // or from file: call d.OpenMTInputFile(file) d.List = listbox1 'd.OptionURL = "ftp://ftp.monkeybreadsoftware.net/test.jpg" d.OptionURL = "sftp://ftp.monkeybreadsoftware.net/test.jpg" d.OptionUpload=true d.OptionUsername = "xxx" // please change URL and credentials d.OptionPassword = "xxx" d.YieldTime = true d.OptionMaxSendSpeed = filesize*0.1 // limit speed so we have a chance to cancel 'd.OptionInFileSize = filesize // set by OpenMTInputFile if firstTime then d.DoCancelLater = true else d.OptionResumeFrom = -1 // append 'd.OptionAppend = true end if e=d.Perform // show debug messages dim dl as string = d.DebugMessages dl = DefineEncoding(dl, encodings.ISOLatin1) // assume linux server with ISO latin1 dl = ReplaceLineEndings(dl, EndOfLine) DebugLog.Text = dl 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
EventHandler Sub Open() // create dummy file to upload file = SpecialFolder.Desktop.Child("upload test.jpg") if not file.Exists then dim p as Picture = LogoMBS(5000) dim j as string = p.GetData(p.FormatJPEG, p.QualityMax) dim b as BinaryStream = BinaryStream.Create(file, true) b.Write j b.Close end if End EventHandler
Property file As FolderItem
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 if ultotal=0 then List.addrow "Uploading..." else List.addrow "Uploading "+Format(ulnow/ultotal,"-0%")+" "+stR(ulnow)+" of "+str(ultotal) end if if DoCancelLater and ulnow > ultotal / 2 then // cancel at 50 % List.addrow "Cancel here" Return true end if End EventHandler
Property DoCancelLater As Boolean
Property List As listbox
End Class
End Project

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


The biggest plugin in space...