Platforms to show: All Mac Windows Linux Cross-Platform
/CURL/FTP/CURLS ftp file upload resume
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 resume
This example is the version from Tue, 16th Sep 2019.
Project "CURLS ftp file upload resume.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 UploadButton Inherits PushButton
ControlInstance UploadButton 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
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run()
dim e as integer = d.Perform
d.log "Result: "+str(e)
End EventHandler
End Control
Control CancelButton Inherits PushButton
ControlInstance CancelButton Inherits PushButton
EventHandler Sub Action()
d.cancelled = true
End EventHandler
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
// check for messages and show them in the listbox
if d<>Nil then
while UBound(d.Messages)>=0
dim p as string = d.Messages(0)
d.Messages.Remove 0
listbox1.AddRow p
wend
end if
End EventHandler
End Control
Private Sub DoUpload()
dim f as FolderItem
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.OptionResumeFrom = -1 // for FTP: Resume from current size
d.YieldTime = true
d.OptionAppend = true
d.OptionUsername = "test"
d.OptionPassword = "xxxx"
Thread1.run
End Sub
Property Private d As UploadCURL
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
if ultotal=0 then
log "Uploading..."
else
log "Uploading "+Format(ulnow/ultotal,"-0%")+" "+stR(ulnow,"0")+" of "+str(ultotal,"0")
end if
Return cancelled
End EventHandler
EventHandler Function Read(count as integer) As string
dim p as int64 = stream.Position
dim s as string = stream.Read(count)
log "Read "+str(lenb(s),"0")+" of "+str(count,"0")+" at "+str(p,"0")
Return s
End EventHandler
EventHandler Function RestartRead() As boolean
log "Restart Read"
stream.position=0
Return false // no error
End EventHandler
EventHandler Function Seek(pos as Int64, whence as integer) As Integer
dim result as integer = kSeekReturnFail
Select case whence
case kSeekOriginCurrent
stream.Position = stream.Position + pos
result = kSeekReturnOk
case kSeekOriginEnd
stream.Position = stream.Length + pos
result = kSeekReturnOk
case kSeekOriginSet
stream.Position = pos
result = kSeekReturnOk
end Select
log "Seeked to "+str(stream.Position,"0")
Return result
End EventHandler
Sub Log(s as string)
// store messages in array
messages.append s
End Sub
Property Messages() As string
Property cancelled As Boolean
Property stream As binaryStream
End Class
End Project
See also:
- /CURL/FTP/CURLS ftp create or folder delete
- /CURL/FTP/CURLS ftp directory listing
- /CURL/FTP/CURLS ftp directory listing with CURLFileInfoMBS
- /CURL/FTP/CURLS ftp directory listing with Web Edition
- /CURL/FTP/CURLS ftp download to desktop with thread
- /CURL/FTP/CURLS ftp file delete
- /CURL/FTP/CURLS ftp file upload direct
- /CURL/FTP/CURLS ftp file upload with progress
- /CURL/FTP/CURLS ftp file upload with thread
- /CURL/FTP/CURLS ftp upload
The items on this page are in the following plugins: MBS CURL Plugin.