SFTP Client

Description

SFTP client accesses files on a remote server using the SSH file transfer protocol (SFTP).

Input

<SFTPClient>
<userLogonReference>userid</userLogonReference>
<password>password</password>
<action>put|get</action>
<server/>
<remoteUser/>
<remotePassword/>
<port/>
<directory/>
<remote/>
<nodeVersionReference/> <fileExtension/>
<fileName/>
 <nodeVersionReferenceType/> <nodeName/> <nodeDescription/>
 <data/>
</SFTPClient>

Action identifies what SFTP action should be performed: put (write a file to the server) or get (read a file from the server).

Server identifier the server to or from which files will be passed. It can be a domain name or an IP address.

remoteUser and remotePassword identify the user and password to access the remote server. Key files are not supported.

Port is optional and identifies the port for SFTP. The default is 22.

Directory indicates the directory in which file operations are to occur. It is optional. The format depends on the server. It may be absolute or relative, depending on the capabilities of the server. By default, SFTP uses absolute, not relative files. Use a directory of ~ to indicate that the remote file is relative to the home directory.

Remote gives the remote file name. It can contain a directory path. Intermediate directories will be created if permitted by the server.

Data can be sent or retrieved in the body of the call or through nodes.

For put, if using nodes, nodeVersionReference identifies the node which holds the file to be sent. If sending data directly, data holds the data. If both are passed, nodeVersionReference takes precedence.

For get, if using nodes, nodeVersionReference identifies the node which will be used to hold the file. It can use a local reference of $auto to automatically generate the reference. If it does not exist, it will be created, using the node type identified by nodeVersionReferenceType, which defaults to system.FILE_TYPE. The fileName defaults to the name of the remote file, which is assumed to be the part of the path after the last / or \ (this means that files on Linux with an embedded \ or on Windows with an embedded / might give the wrong results). The fileExtension default to the extension on the fileName. The name and description of the file can be set.

For get, if returning the data directly, don't set nodeVersionReference.

Output

The output depends on the operation.

For a put operation, it simply returns.

<SFTPClient>
<errorNumber>0</errorNumber>
</SFTPClient>

For a get operation with a node version reference, it returns the nodeVersionReference. If the $auto option is used, this will show the created node version reference.

<SFTPClient>
<errorNumber>0</errorNumber>
<nodeVersionReference>path.to.file.node</nodeVersionReference>
</SFTPClient>

For a get operation without a node version reference, it returns in data the contents of the file, as a string.

<SFTPClient>
<errorNumber>0</errorNumber>
<data>... File contents ...</data>
</SFTPClient>

Errors

100 - General error. This is used for all errors returned from remote server, other than not found.
101 - Not authorised
102 - Not found (either node not found or remote file not found)
103 - Parameter error

Class

com.metrici.xerula.SFTPClientService