Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/SFTP/CURLS sftp batch download
Required plugins for this example: MBS CURL Plugin
Last modified Tue, 16th Mar 2026.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /CURL/SFTP/CURLS sftp batch download
Download this example: CURLS sftp batch download.zip
Project "CURLS sftp batch download.xojo_binary_project"
FileTypes
Filetype Text
End FileTypes
Class MainWindow Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
DownloadListing url.Text
End EventHandler
End Control
Control LogList Inherits ListBox
ControlInstance LogList Inherits ListBox
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control user Inherits TextField
ControlInstance user Inherits TextField
End Control
Control pass Inherits TextField
ControlInstance pass Inherits TextField
End Control
Control Bar Inherits ProgressBar
ControlInstance Bar Inherits ProgressBar
End Control
Control ProgressLabel Inherits Label
ControlInstance ProgressLabel Inherits Label
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
CurlMulti.Perform
End EventHandler
End Control
EventHandler Sub Open()
CurlMulti = new CURLMulti
CurlMulti.list = LogList
CurlMulti.ProgressLabel = ProgressLabel
CurlMulti.Bar = bar
CurlMulti.MaxTotalConnections = 10
End EventHandler
Sub DownloadFile(name as string, folderURL as string)
// load a file
dim e as integer
dim d as new CURLSMBS
d.OptionURL = FolderURL + name
d.OptionDirListOnly = True
d.OptionSSHAuthTypes = 2+8 // password, not public key
d.OptionUsername = user.Text
d.OptionPassword = pass.Text
d.CollectOutputData = false
d.CollectDebugMessages = true
d.CollectHeaders = true
dim file as FolderItem = SpecialFolder.Desktop.Child(name)
if not d.CreateMTOutputFile(file) then
MsgBox "Failed to create file: "+name
return
end if
if CurlMulti.AddCURL(d) then
// ok
else
Break
end if
CurlMulti.MyTransfersTotal = CurlMulti.MyTransfersTotal + 1
bar.Value = CurlMulti.MyTransfersDone
bar.Maximum = CurlMulti.MyTransfersTotal
bar.Visible = true
ProgressLabel.Text = "Load file "+name
'LogList.AddRow str(CurlMulti.MyTransfersDone)+" of "+str(CurlMulti.MyTransfersTotal)
End Sub
Sub DownloadListing(FolderURL as string)
// list files in folder
ProgressLabel.Text = "Start..."
ProgressLabel.Visible = true
CurlMulti.MyTransfersDone = 0
CurlMulti.MyTransfersTotal = 1
dim e as integer
dim d as new CURLSMBS
d.OptionURL = FolderURL
d.OptionDirListOnly = True
d.OptionSSHAuthTypes = 2+8 // password, not public key
d.OptionUsername = user.Text
d.OptionPassword = pass.Text
d.CollectOutputData = true
d.CollectDebugMessages = true
d.CollectHeaders = true
if CurlMulti.AddCURL(d) then
// ok
else
Break
end if
bar.Value = CurlMulti.MyTransfersDone
bar.Maximum = CurlMulti.MyTransfersTotal
bar.Visible = true
'LogList.AddRow str(CurlMulti.MyTransfersDone)+" of "+str(CurlMulti.MyTransfersTotal)
End Sub
Property CurlMulti As CURLMulti
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 CURLMulti Inherits CURLSMultiMBS
EventHandler Sub TransferFinished(curl as CURLSMBS, result as Integer, RemainingFinishedTransfers as Integer)
dim DebugMessage as string = Curl.DebugMessages
MyTransfersDone = MyTransfersDone + 1
// view in debugger
dim u as CURLSMBS = curl
dim m as string
Select case result
case CURLSMBS.kError_LOGIN_DENIED
m = "Wrong password."
case CURLSMBS.kError_UNSUPPORTED_PROTOCOL
m = "Protocol not implemented."
case CURLSMBS.kError_COULDNT_CONNECT
m = "Failed to connect."
case CURLSMBS.kError_FAILED_INIT
m = "Failed to initialize."
case CURLSMBS.kError_OK
m = "No error."
else
m = "Error "+str(result)
end select
List.addrow "Finished "+curl.OptionURL
if result <> 0 then
Break
end if
if curl.OptionDirListOnly then
// got list of files
dim list as string = curl.OutputData
list = ReplaceLineEndings(list, EndOfLine)
dim files() as string = split(list, EndOfLine)
// download all
for each filename as string in files
if filename = "" then continue
if filename.left(1) = "." then continue // skip folders or invisible files
// start a download
MainWindow.DownloadFile filename, curl.OptionURL
next
else
// file loaded
ProgressLabel.Text = str(MyTransfersDone)+" of "+str(MyTransfersTotal)
bar.Value = MyTransfersDone * 100 / MyTransfersTotal
end if
'list.addrow str(self.MyTransfersDone)+" of "+str(self.MyTransfersTotal)
if MyTransfersDone = MyTransfersTotal then
MyTransfersTotal = -1
list.AddRow "All downloads done."
ProgressLabel.Text = "done"
bar.Visible = false
end if
End EventHandler
Property MyTransfersDone As Integer
Property MyTransfersTotal As Integer = -1
Property ProgressLabel As label
Property bar As ProgressBar
Property list As Listbox
End Class
Sign
End Sign
End Project
See also:
- /CURL/SFTP/CURLS sftp batch upload
- /CURL/SFTP/CURLS SFTP Client
- /CURL/SFTP/CURLS sftp directory listing
- /CURL/SFTP/CURLS sftp rename file
- /CURL/SFTP/CURLS sftp rename file batch
- /CURL/SFTP/CURLS sftp upload
- /CURL/SFTP/CURLS sftp upload console
Download this example: CURLS sftp batch download.zip
The items on this page are in the following plugins: MBS CURL Plugin.