UploadFile with SFTPClient

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

UploadFile with SFTPClient

Post by pfrossard » Wed 02 Jun 2010 17:31

I try to send a file using UploadFile,
Example : uploadfile('c:\temp\test.txt', '/root/test.txt', True);
On windows XP,
If the file doesn't exist (on the server) :
The error is "Invalid file handle" but the file is correct on the server,
If the file exist (on the server) :
The error is "Failure" ... and the file is not overwrite !

pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

Post by pfrossard » Wed 02 Jun 2010 22:08

See the log from openssh-server 1:5.1p1-5 :

Jun 2 23:01:45 pluton sshd[5146]: Accepted password for root from 192.168.0.1 port 1312 ssh2
Jun 2 23:01:45 pluton sshd[5146]: subsystem request for sftp
Jun 2 23:01:45 pluton sftp-server[5148]: session opened for local user root from [192.168.0.1]
Jun 2 23:01:45 pluton sftp-server[5148]: received client version 3
Jun 2 23:01:45 pluton sftp-server[5148]: debug3: request 1: open flags 42
Jun 2 23:01:45 pluton sftp-server[5148]: open "/root/1.txt" flags WRITE,CREATE,EXCL mode 0666
Jun 2 23:01:45 pluton sftp-server[5148]: debug3: request 1: sent status 4
Jun 2 23:01:45 pluton sftp-server[5148]: sent status Failure
Jun 2 23:01:48 pluton sftp-server[5148]: debug1: read eof
Jun 2 23:01:48 pluton sftp-server[5148]: session closed for local user root from [192.168.0.1]

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 03 Jun 2010 09:55

Please check if the directory "/root/" exists and SFTP server has permission to create files in this directory.
Also check if the problem can be reproduced if any third-party SFTP client is used.

pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

Post by pfrossard » Thu 03 Jun 2010 10:56

Yes, the directory exist ...

I made a simple porgram :

ScSFTPClient1.Initialize;
ScSFTPClient1.UploadFile('1.txt', '/root/ibox/1.txt', True);
ScSFTPClient1.Disconnect;

If NonBlocking = True

Jun 3 11:46:45 pluton sftp-server[4127]: session opened for local user root from [192.168.0.1]
Jun 3 11:46:45 pluton sftp-server[4127]: received client version 3
Jun 3 11:46:45 pluton sftp-server[4127]: debug3: request 1: open flags 26
Jun 3 11:46:45 pluton sftp-server[4127]: open "/root/ibox/1.txt" flags WRITE,CREATE,TRUNCATE mode 0666
Jun 3 11:46:45 pluton sftp-server[4127]: debug1: request 1: sent handle handle 0
Jun 3 11:46:45 pluton sftp-server[4127]: debug1: read eof
Jun 3 11:46:45 pluton sftp-server[4127]: forced close "/root/ibox/1.txt" bytes read 0 written 0
Jun 3 11:46:45 pluton sftp-server[4127]: session closed for local user root from [192.168.0.1]

Without result ? (in OnError or OnSuccess)

If NonBlocking = False

Jun 3 11:46:40 pluton sftp-server[4097]: session opened for local user root from [192.168.0.1]
Jun 3 11:46:40 pluton sftp-server[4097]: received client version 3
Jun 3 11:46:40 pluton sftp-server[4097]: debug3: request 1: open flags 26
Jun 3 11:46:40 pluton sftp-server[4097]: open "/root/ibox/1.txt" flags WRITE,CREATE,TRUNCATE mode 0666
Jun 3 11:46:40 pluton sftp-server[4097]: debug1: request 1: sent handle handle 0
Jun 3 11:46:40 pluton sftp-server[4097]: debug1: request 2: write "/root/ibox/1.txt" (handle 0) off 0 len 9224
Jun 3 11:46:40 pluton sftp-server[4097]: debug3: request 2: sent status 0
Jun 3 11:46:40 pluton sftp-server[4097]: sent status Success
Jun 3 11:46:40 pluton sftp-server[4097]: debug3: request 3: close handle 0
Jun 3 11:46:40 pluton sftp-server[4097]: close "/root/ibox/1.txt" bytes read 0 written 9224
Jun 3 11:46:40 pluton sftp-server[4097]: debug3: request 3: sent status 0
Jun 3 11:46:40 pluton sftp-server[4097]: sent status Success
Jun 3 11:46:40 pluton sftp-server[4097]: debug1: read eof
Jun 3 11:46:40 pluton sftp-server[4097]: session closed for local user root from [192.168.0.1]

Result : Success

pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

Post by pfrossard » Thu 03 Jun 2010 11:08

Ok,
If NonBlocking = True,
I cannot disconnect after the upload command,
I cannot disconnect inside the success event,
After which event could I close the connexion ?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 03 Jun 2010 12:48

You can close connection in the OnSuccess event handler when Operation is equal to opClosingHandle.

pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

Post by pfrossard » Thu 03 Jun 2010 13:32

Yes, It's correct,
When you upload file there is two event success,
opWritingFile and opClosingHandle,
On the second event I close the connexion successfuly,
Thanks.

pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

Post by pfrossard » Thu 03 Jun 2010 15:19

After an upload,
I can not open the file uploaded in the function AfterDisconnect or OnSuccess (after the opClosingHandle) !
With CreateFile the error is 32 ...

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 04 Jun 2010 12:31

Now you can open file in the OnSuccess event handler only after client is disconnected.
We will change this behaviour in the next SecureBridge build.

pfrossard
Posts: 19
Joined: Thu 08 Apr 2010 09:25

Post by pfrossard » Fri 04 Jun 2010 14:37

For DownloadFile function also ...

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 07 Jun 2010 08:22

Ok, we will fix.

Post Reply