Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/SFTP/CURLS sftp directory listing
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/SFTP/CURLS sftp directory listing
This example is the version from Wed, 3rd Jan 2023.
Project "CURLS sftp directory listing.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
DoDownload
End EventHandler
End Control
Control URL Inherits TextField
ControlInstance URL Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
End Control
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
End Control
Control RadioMode Inherits RadioButton
ControlInstance RadioMode(0) Inherits RadioButton
ControlInstance RadioMode(1) Inherits RadioButton
ControlInstance RadioMode(2) Inherits RadioButton
End Control
Private Sub DoDownload()
dim s as string
dim e as integer
dim d as DownloadCURL
d=new DownloadCURL
d.CollectDebugMessages = true
d.CollectOutputData = true
d.OptionVerbose = true
d.OptionURL = ConvertEncoding(url.text, encodings.ISOLatin1) // our server uses ISOLatin1...
d.OptionUsername = "xxx"
d.OptionPassword = "yyy"
if RadioMode(0).Value then
// simple listing
d.OptionDirListOnly = true
elseif RadioMode(2).Value then
// direct with command
d.OptionCustomRequest = "MLSD"
else
// verbose listing
d.OptionDirListOnly = false
end if
e = d.Perform
select case e
case 0
// get output and show it. Maybe fix encoding
s = d.OutputData
if s.Encoding = nil then
if encodings.UTF8.IsValidData(s) then
s = DefineEncoding(s, encodings.UTF8)
else
s = DefineEncoding(s, encodings.ISOLatin1)
end if
end if
s = ReplaceLineEndings(s, EndOfLine)
editfield1.text=s
else
s=""
// show debug messages
s = d.DebugMessages
if s.Encoding = nil then
if encodings.UTF8.IsValidData(s) then
s = DefineEncoding(s, encodings.UTF8)
else
s = DefineEncoding(s, encodings.ISOLatin1)
end if
end if
s = ReplaceLineEndings(s, EndOfLine)
editfield1.text=s
end select
ResultText.text="Result: "+str(e)+" "+d.LasterrorMessage
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 DownloadCURL Inherits CURLSMBS
EventHandler Function Progress(dltotal as Int64, dlnow as Int64, ultotal as Int64, ulnow as Int64, percent as double) As boolean
if dltotal=0 then
window1.ResultText.text="Downloading..."
else
window1.ResultText.text="Downloading "+Format(dlnow/dltotal,"0%")
end if
Return false
End EventHandler
End Class
End Project
See also:
The items on this page are in the following plugins: MBS CURL Plugin.