Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/FTP/CURLS ftp 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/FTP/CURLS ftp directory listing
This example is the version from Wed, 3rd Jan 2023.
Project "CURLS ftp directory listing.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class MainWindow 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 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
Control StaticText11 Inherits Label
ControlInstance StaticText11 Inherits Label
End Control
Control StaticText111 Inherits Label
ControlInstance StaticText111 Inherits Label
End Control
Control NameField Inherits TextField
ControlInstance NameField Inherits TextField
End Control
Control PassField Inherits TextField
ControlInstance PassField Inherits TextField
End Control
Control ResultText Inherits Label
ControlInstance ResultText Inherits Label
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=url.text
d.OptionUsername = NameField.Text
d.OptionPassword = PassField.Text
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
// 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
select case e
case 0
s = " = OK"
case 9
s=" = CURLE_FTP_ACCESS_DENIED"
case 67
s=" = CURLE_LOGIN_DENIED"
else
s=""
dim de as string = d.DebugMessages
Break
end select
ResultText.text="Result: "+str(e)+s
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
MainWindow.ResultText.text="Downloading..."
else
MainWindow.ResultText.text="Downloading "+Format(dlnow/dltotal,"0%")
end if
Return false
End EventHandler
End Class
End Project
See also:
- /CURL/FTP/CURLS ftp directory browsing
- /CURL/FTP/CURLS ftp directory listing with CURLFileInfoMBS
- /CURL/FTP/CURLS ftp download to desktop
- /CURL/FTP/CURLS ftp file upload
- /CURL/FTP/CURLS ftp file upload direct
- /CURL/FTP/CURLS ftp file upload resume
- /CURL/FTP/CURLS ftp file upload with thread
- /CURL/FTP/CURLS ftp file uploads
- /CURL/FTP/CURLS ftp secure upload
- /CURL/FTP/CURLS ftp upload
The items on this page are in the following plugins: MBS CURL Plugin.