How to upload a file MBSCURL / SCP

With MBSCURL plugin, I can upload a text data by scp. It works well.
I need to upload a local file to a remote server but I can’t find any example.

Can anyone point the place I could go over?

Did you check examples?

You can use CURLSMBS.OpenMTInputFile method to open the folderitem before transfer to use it as data to upload.

Instead of SetInputData method.

Yes, that is what I wanted to check. BTW, no example?

All the FTP examples work fine for SFTP.
But I can make one for that function.

Thanks. I will try that first.

It works.

  dim d as new UploadCURL
  bs = BinaryStream.Open(f)
  .................... = bs

Only one problem. From windows to Linux, it seems that there is something wrong in EndOfLine.

If the original data is a text, I can use below code but I am not sure what I should do for the BinaryStream.


Using Binarystream is not needed in 90% of the cases.
Like below just using d.OpenMTInputFile is enough.

[code] dim f as FolderItem = GetOpenFolderItem(“all”)
if f = nil then Return

dim d as new UploadCURL

if d.OpenMTInputFile(f) then
// ok
MsgBox “Failed to open file.”
end if

d.OptionVerbose = true // generate messages
d.CollectDebugData = true // collect them

d.OptionUsername = “test”
d.OptionPassword = “xxxx”
d.OptionSSHAuthTypes = 2+8 // for SFTP: only allow keyboard or interactive login, no public key

dim e as integer = d.Perform

dim DebugMessages as string = d.DebugData
// check those in debugger in case of errors

listbox1.addrow "Result: "+str(e)

if e <> 0 then
end if[/code]


Can you let me know how to handle EndOfLine with d.OpenMTInputFile(f)?
Uploading the file works fine but I see lots of ^M and no CR in the file.

the file is uploaded in binary mode as is.

But you can of course load it first into memory, replace line endings and pass it via SetInputData.

Great. Everything works fine.

Thank you so much!