Home > Class Reference > %SYS namespace > %Net.SSH.SFTP

%Net.SSH.SFTP

class %Net.SSH.SFTP extends %Library.RegisteredObject

A wrapper object for an SFTP session running over and existing SSH connection. Use the OpenSFTP() method of a previously connected and authenticated %Net.SSH.Session to instantiate a valid SFTP object for use.
You should NOT create instances of %Net.SSH.SFTP directly!
NOTE: %Net.SSH is currently not supported on OpenVMS platforms.

Property Inventory

Method Inventory

Properties

property SSH as %Net.SSH.Session;
SSH Session that hosts this SFTP session.
Property methods: SSHGet(), SSHGetSwizzled(), SSHIsValid(), SSHNewObject(), SSHSet()

Methods

method %OnClose() as %Status [ Language = objectscript ]
Clean up any resources
method CloseSFTP() as %Status [ Language = objectscript ]
Close the SFTP session
method Delete(file As %String) as %Status [ Language = objectscript ]
Delete a file on the remote server
method Dir(directory As %String, ByRef contents, spec As %String = "", dotFiles As %Boolean = 0) as %Status [ Language = objectscript ]
Enumerate the contents of a directory. Populates the contents array with $LIST entries for each file in the directory, subscripted by a integer sequence, the $LIST is composed in the same format as with the FileInfo() method. ()
The optional spec parameter allows for wildcards when searching the directory. The wildcards that can be used are as follows:
  • *: Match zero or more characters
  • ?: Match exactly one character
Some examples are:
*.txt
journal_???.*
201?-??-??.log
method DirEnum(directory As %String, oref As %RegisteredObject, method As %String) as %Status [ Language = objectscript ]
Enumerate the contents of a directory by calling the specified instance method once for each entry in the directory. The signature of the callback should take two arguments, first an integer sequence number and secondly a $LIST composed in the same format as with the FileInfo() method (see FileInfo).
method FileInfo(file As %String, ByRef info As %List) as %Status [ Language = objectscript ]
Gets information about a file. On return, info is a $LIST containing: 1) Filename 2) Size 3) File type P: Named pipe (FIFO) C: Character special D: Directory B: Block special F: Regular file L: Symbolic link S: Socket U: Unknown 4) Permissions 5) UID 6) GID 7) Last Access Time 8) Last Modification Time Depending on the remote system, some information may not be available and will be indicated by a null list element.
method Get(remote As %String, local As %String, localmode As %String = "0600", append As %Boolean = 0) as %Status [ Language = objectscript ]
Get a file from the remote system, storing it in the local file system with the specified mode (access).
method GetBufferSize(ByRef pBufferSize As %Integer) as %Status [ Language = objectscript ]
Gets the transfer buffer size for SFTP operations (in bytes).
method GetStream(remote As %String, ByRef stream As %Stream.Object, append As %Boolean = 0) as %Status [ Language = objectscript ]
Get a file from the remote system, storing it in the stream. If stream not defined on entry it will create a stream for this automatically. If stream is a file stream we will just link to the file we created.
classmethod H2UTCFileTime(horolog As %String) as %Integer [ Language = objectscript ]
Convert $HOROLOG to UNIX file time; note that UNIX time is the number of seconds since Midnight Jan 1, 1970 which has a $HOROLOG date of 47117,0
method MkDir(directory As %String, remotemode As %String = "0700") as %Status [ Language = objectscript ]
Create a new directory on the remote server, with the specified file mode (access).
classmethod Permissions2Text(permissions As %Integer) as %String [ Language = objectscript ]
Convert UNIX permissions flags to a string
method Put(local As %String, remote As %String, remotemode As %String = "0600", append As %Boolean = 0) as %Status [ Language = objectscript ]
Put a file from the local filesystem to the remote server, setting the specified mode (access).
method PutStream(stream As %Stream.Object, remote As %String, remotemode As %String = "0600", append As %Boolean = 0) as %Status [ Language = objectscript ]
Put a stream to the remote system, setting the specified mode (access). If stream is a file stream we will just link to the file already present, otherwise we create a temp file to send.
method Rename(old As %String, new As %String) as %Status [ Language = objectscript ]
Rename a file on the remote server
method RmDir(directory As %String) as %Status [ Language = objectscript ]
Remove a directory on the remote server
method SetBufferSize(pBufferSize As %Integer) as %Status [ Language = objectscript ]
Sets the transfer buffer size for SFTP operations (in bytes). The default is 1MB, performance may be degraded when this is set to small values.
method SetFileTime(remote As %String, atimeUTC As %TimeStamp, mtimeUTC As %TimeStamp) as %Status [ Language = objectscript ]
Change the access and last modification times for the specified file (you must be the current owner or root). NOTE: Timestamp values must be in UTC time (see $ZTIMESTAMP).
method SetOwnerAndGroup(remote As %String, uid As %Integer, gid As %Integer) as %Status [ Language = objectscript ]
Change the uid/gid for the specified file or directory (you must be the current owner or root).
method SetPermissions(remote As %String, mode As %String) as %Status [ Language = objectscript ]
Change the permissions mode for the specified file or directory.
method SetSize(remote As %String, size As %Integer) as %Status [ Language = objectscript ]
Change the size of the specified file (by either truncating or extending it).
Create a symlink on the remote server
classmethod Test(host As %String, username As %String, password As %String, dir As %String = "/etc", spec As %String = "", dotFiles As %Boolean = 1, ByRef t) as %Status [ Language = objectscript ]
Demonstrates use of an SFTP session to enumerate the contents of the /etc directory on the remote server.
classmethod TestPut(host As %String, username As %String, password As %String, srcfile As %String, destfile As %String) as %Status [ Language = objectscript ]
Demonstrates use of an SFTP session to put a file to the remote server.
method Touch(remote As %String) as %Status [ Language = objectscript ]
Touch the file to have an access time of now.
classmethod UTCFileTime2H(filetime As %Integer) as %String [ Language = objectscript ]
Convert UNIX file time to $HOROLOG, for UNIX time is the number of seconds since Midnight Jan 1, 1970 which has a $HOROLOG date of 47117,0

Inherited Methods