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.

                                   
Important:

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.

Note:

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

sftp.Connection

Object

Server scripts

Represents a connection to the account on the remote FTP server.

Method

sftp.createConnection(options)

sftp.Connection

Server scripts

Establishes a connection to a remote FTP server.

Enum

sftp.MAX_CONNECT_TIMEOUT

Enum

Server scripts

Holds the values for maximum connection timeout.

sftp.MIN_CONNECT_TIMEOUT

Enum

Server scripts

Holds the values for minimum connection timeout.

sftp.MAX_PORT_NUMBER

Enum

Server scripts

Holds the values for the maximum port number.

sftp.MIN_PORT_NUMBER

Enum

Server scripts

Holds the values for the minimum port number.

sftp.DEFAULT_PORT_NUMBER

Enum

Server scripts

Holds the values for the default port number.

sftp.Sort

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

Connection.download(options)

file.File

Server scripts

Downloads a file from the remote FTP server.

Connection.upload(options)

void

Server scripts

Uploads a file to the remote FTP server.

Connection.makeDirectory(options)

string

Server scripts

Creates an empty directory.

Connection.removeDirectory(options)

void

Server scripts

Removes an empty directory.

Connection.removeFile(options)

void

Server scripts

Removes a file in a directory.

Connection.move(options)

void

Server scripts

Moves a file or directory from one location to another.

Connection.list(options)

Array<Object>

Server scripts

Lists the remote directory.

Enum

Connection.MAX_FILE_SIZE

number

Server scripts

Holds the values for the maximum file size.

Connection.MAX_TRANSFER_TIMEOUT

number

Server scripts

Holds the values for the maximum transfer timeout.

Related Support Articles

SuiteScript > sftp Module > Connection.upload(options) > Execution Logs > FTP_PERMISSION_DENIED
SuiteScript 2.0 > n/sftp > FTP_INVALID_DIRECTORY
One SFTP Connection Established per Every File Upload/Download Using sftp.createConnection() Function

Related Topics

Setting up an SFTP Transfer
SFTP Authentication
Supported Cipher Suites and Host Key Types
Supported SuiteScript File Types
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices