Connection.download(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Downloads a file from the remote FTP server.

Returns

file.File Object

Supported Script Types

Server scripts

For more information, see SuiteScript 2.x Script Types.

Governance

100 units

Module

N/sftp Module

Since

2016.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.filename

string

required

The name of the file to download.

2016.2

options.directory

string

optional

The relative path to the directory that contains the file to download.

By default, the path is set to the current directory.

Important:

This input must take the form of a relative path.

2016.2

options.timeout

number

optional

The number of seconds to allow for the file to download.

By default, this value is set to 300 seconds.

2016.2

Errors

Error Code

Thrown If

FTP_MAXIMUM_FILE_SIZE_EXCEEDED

The file size is greater than the maximum file size allowed by NetSuite.

FTP_NO_SUCH_FILE_OR_DIRECTORY

The file or directory does not exist.

FTP_TRANSFER_TIMEOUT_EXCEEDED

The transfer is taking longer than the specified options.timeout value.

FTP_INVALID_TRANSFER_TIMEOUT

The options.timeout value is either a negative value, zero or greater than 300 seconds.

FTP_PERMISSION_DENIED

Access to the file or directory on the remote FTP server was denied.

CONNECTION_RESET

The connection was reset.

THE_REMOTE_PATH_FOR_FILE_IS_NOT_VALID

The file’s remote path is invalid.

CONNECTION_CLOSED_BY_HOST

The connection was closed by the host.

Syntax
Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/sftp Module Script Samples.

          //Add additional code
...

var downloadedFile = objConnection.download({
    directory: 'relative/path/to/file',
    filename: 'downloadMe.js'

});
...
//Add additional code 

        

Related Topics

sftp.Connection
N/sftp Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices