FTP

Sorry for my previous unintended noise.

So this is more fixed code.
The URL must be sftp for file transfers via SSH.
OptionVerbose, CollectDebugData are on, so we can get the debug messages after the transfer and show them in listbox.

[code] dim f as FolderItem
dim e as integer
dim d as UploadCURL
dim b as BinaryStream

f=GetOpenFolderItem(“all”)
if f=nil then Return

b = BinaryStream.Open(f)

d=new UploadCURL
d.stream=b
d.OptionURL=“sftp://xxx/var/www/html/ews/xojo”
d.OptionUsername = “xxx”
d.OptionPassword = “xxx”
'd.OptionPort = 22
d.OptionVerbose = true
d.OptionUpload=true
d.OptionInFileSize=b.Length
d.CollectDebugData = true

e=d.Perform

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

dim t as string = d.DebugData

t = ReplaceLineEndings(t, EndOfLine)
dim lines() as string = split(t, EndOfLine)

for each line as string in lines
Listbox1.AddRow line
next
[/code]

Please try it and make sure you have right domain/IP in the URL.

Thanks Christian Schmitz,

While I run the above code , Xojo through the below error

Connected to 192.168.1.135 (192.168.1.135) port 22 (#0)
SSH MD5 fingerprint: 332b40e4f92a238e2ef6351d2540d7a6
SSH authentication methods available: publickey,password
Using SSH public key file ‘(nil)’
Using SSH private key file ‘’
SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file
Initialized password authentication
Authentication complete
Upload failed: Operation failed (4/-31)
Connection #0 to host 192.168.1.135 left intact

Kindly advice whether i missed anything…

sorry, sounds strange.
Can you check what events fire?
Like does read event fire and fail to read?

So CURL opens SSH channel which gives errno = -31 and SSH error number 4 (LIBSSH2_FX_FAILURE).

-31 is LIBSSH2_ERROR_SFTP_PROTOCOL
An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server.

Now do you have logs on the server about this?

[quote=217579:@Christian Schmitz]sorry, sounds strange.
Can you check what events fire?
Like does read event fire and fail to read?[/quote]

Christian , Read event was not fire.

[quote=217583:@Christian Schmitz]-31 is LIBSSH2_ERROR_SFTP_PROTOCOL
An invalid SFTP protocol response was received on the socket, or an SFTP operation caused an errorcode to be returned by the server.

Now do you have logs on the server about this?[/quote]

Christian ,
Sever don’t have any logs for this.

Adding to this ,

I have tried the 3 different server, xojo provides the same error code.
But I can connect the server using the FileZillaClient application

Anyone help me out form the above issue

does this server have an IP from outside?
So you could send me project with credentials to test?

I came across this thread because I’m presently mucking about myself with SFTP (have done traditional FTP for years) with Christian’s plugin. I know this is a couple of years ago, but I’ll chime in anyway :slight_smile:

With SFTP, I have found that I have to add the trailing slash ("/") in OptionURL, to complete the path. Otherwise, the directory listing that I get will be of the account root, and other unexpected things will happen. I don’t see this in your sample code.

I say this on the presumption that “xojo” is the target directory, but what this code is trying to do is to upload a file that will be named “xojo” on the server. If this the case, OptionURL should end in …/xojo/filename.