N/sftp Module
Use the N/sftp module to manage folders and upload or download files from external SSH file transfer (SFTP) servers. You can perform the following SFTP functions using the N/sftp module:
SFTP servers can be hosted by your organization or by a third party. NetSuite does not provide SFTP server functionality. All SFTP transfers to or from NetSuite must originate from SuiteScript. It is not possible for external clients to initiate file transfers using SFTP.
Use SSH keys to establish an SFTP connection. By using the keys, you can manage files and directories by using the SFTP protocol. For more information, see SSH Keys for SFTP. For more information about working with keys in SuiteScript, see the N/keyControl Module, see N/keyControl Module.
All paths, directories, and filenames that contain wildcards such as ?
and *
must have those characters escaped, unless these characters are specifically intended to work as wildcards.
To use an external server to initiate a NetSuite file transfer that doesn’t use SFTP, you can use RESTlets or SOAP web services. In SuiteScript, RESTlets can respond to requests containing file data and save them in the File Cabinet. RESTlets can also respond to requests for file data by loading the contents from the File Cabinet and returning them in the response. Note that binary file content must be received or sent as Base64 encoded Strings. See SuiteScript 2.x RESTlet Script Type for more information.
In SOAP web services, applications can invoke CRUD operations on the file record to populate or change the contents of the File Cabinet. See SuiteTalk SOAP Web Services Platform Guide and File for more information.
In This Help Topic
N/sftp Module Members
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Object |
Object |
Server scripts |
Represents a connection to the account on the remote FTP server. |
|
Method |
Server scripts |
Establishes a connection to a remote FTP server. |
||
Enum |
Enum |
Server scripts |
Holds the values for maximum connection timeout. |
|
Enum |
Server scripts |
Holds the values for minimum connection timeout. |
||
Enum |
Server scripts |
Holds the values for the maximum port number. |
||
Enum |
Server scripts |
Holds the values for the minimum port number. |
||
Enum |
Server scripts |
Holds the values for the default port number. |
||
Enum |
Server scripts |
Holds the values to be used to sort the listed directory. |
Connection Object Members
The following members are called on the sftp.Connection object.
Member Type |
Name |
Return Type / Value Type |
Supported Script Types |
Description |
---|---|---|---|---|
Method |
Server scripts |
Downloads a file from the remote FTP server. |
||
void |
Server scripts |
Uploads a file to the remote FTP server. |
||
string |
Server scripts |
Creates an empty directory. |
||
void |
Server scripts |
Removes an empty directory. |
||
void |
Server scripts |
Removes a file in a directory. |
||
void |
Server scripts |
Moves a file or directory from one location to another. |
||
Array<Object> |
Server scripts |
Lists the remote directory. |
||
Enum |
number |
Server scripts |
Holds the values for the maximum file size. |
|
number |
Server scripts |
Holds the values for the maximum transfer timeout. |