Back to product page

PutFile function


Stores data from a fixed-size buffer to a remote file, at a given position.

Type

A Long value. If successful, 0 is returned, otherwise error as specified here

Syntax

  • C
long Sftp_PutFile(void *Sftp, char *LocalFile, char *RemotePath);
The PutFile(void *Sftp,char *LocalFile,char *RemotePath) syntax has these parts:
void *SftpHandle of the created Sftp instance.
char *LocalFileFull path to a file on local computer.
char *RemotePathFull path to a file/directory on the server.

Remarks

The PutFile function will initiate copying of a file from the local computer to the remote server that you are connected to. During the transfer, the Progress callback will be called several times, depending on your network connection speed and the size of the file. When the copy is complete, the Done callback will be invoked.

If an error occurs during the transfer, the Done callback containing an ErrorCode and a description for the error, will be invoked immediately and the transfer will be aborted. If you want to continue the transfer later, or you want to resend the file, initiate the PutFile function again (immediately or after reconnecting, depending on the error that occurred). You may also use the Resume property to resume the transfer from the position where the error occurred.

This function can be initiated only when the State property is set to Connected. You cannot send a file if wodSFTP is busy doing something else.

Although the LocalFile argument MUST contain the full path including the filename of the file you wish to send, you can omit the RemotePath argument. For instance, you can set:
 
RemotePath = "/tmp"
 

in which case wodSFTP will automatically copy it using the same name that it has locally. If you want to copy it with another name, you should include the name in the RemotePath argument.

If you don't specify the LocalFile or RemotePath arguments, wodSFTP will use the values set in the LocalPath and RemotePath properties.

No wildcards can be used in the RemotePath argument. The RFC protocol specification for SFTP does not allow them.

Platforms

Windows