Description
-
Uploads multiple files in a sequence, recursive.
Return type
- A Long value. If successful, 0 is returned, otherwise
error as specified here.
Syntax
-
long Sftp_PutFiles(void *Sftp, char *LocalPath, char
*RemotePath, int MaxLevel);
The PutFiles function syntax
has these parts:
| void
*Sftp |
Handle of the created Sftp
instance. |
| char *LocalFile |
Full path to a file/directory on
local computer. |
| char *RemotePath |
Full path to a
file/directory on the server. |
| int MaxLevel |
Specifies maximum number of
subdirectory levels to copy. 0 for unlimited. |
Remarks
-
This function will try to upload local directory structure from
local disk to the server. You need to specify
LocalPath argument that points to a directory from where
files are copied, and RemotePath that
determines location where those files are placed on the server.
PutFiles will go and recursive copy directories and files -
corresponding directory structure will also be created on the
server.
wodSFTP will go up to MaxLevel deep
into recursion. Default value is 5 - meaning up to 5 subdirectory
levels will be copied. You can specify any value for
MaxLevel. If you specify 0, that means
that no restriction exists for recursion depth.
Before each item is copied,
LoopItem callback
will be called, specifying local name of the file/folder, its remote
name (including full path in both cases), type of the item
(file/folder) and will allow you to Skip
the item so it is not copied to the server at all. Make sure
your logic for setting Skip = True
is correct - if you skip creation of remote directory and then try
to upload files to it, you may get more errors! Since PutFiles does
not support wildcards (for example, you cannot specify "*.TXT" in
PutFiles call), LoopItem is a place to determine if certain item
matches your wildcard expression (if you have any), so you can skip
files that doesn't match your criteria.
If an errors occurs during file upload,
LoopError
callback is called holding error number and error description of the
error. If you leave ErrorCode argument
in LoopError callback as is - PutFiles operation will be aborted. If
you change ErrorCode value in LoopError
callback to 0, then PutFiles operation will continue (ignoring the
error) normally.
Do not forget that RemotePath should always
specify full absolute path (i.e. /home/joe/something) instead of
relative path (i.e. joe/something). LocalPath should also specify
full path (i.e. C:\home\joe\something) instead of relative path
(i.e. joe\something).
|