Modules

filter

 

Objects/Functions

module (N/sftp)

SuiteScript 2.0

Supported SuiteScript File Types

// Please search https://system.netsuite.com/app/help/helpcenter.nl?search=Supported SuiteScript File Types for more information.


Warning: implode(): Invalid arguments passed in /home/web131/public_html/ns/index_include.php on line 90

Example:

// Code Example 1
//...
var downloadedFile = sftp.download({...});
downloadedFile.folder = 1234;
downloadedFile.save();
//...

// Code Example 2
require(['N/sftp', 'N/file'],
function (sftp, file)
{

var connection = sftp.createConnection({
/*
The Username supplied by the administrator of the external SFTP server.
*/
username: 'myuser',
/*
Refers to the Password supplied by the administrator of the external SFTP server.

The Password Token/GUID obtained by reading the form POST parameter associated
with user submission of a form containing a Credential Field.


Value would typically be read from a custom field.
*/
passwordGUID: "B34672495064525E5D65032D63B52301",
/*
The URL supplied by the administrator of the external SFTP server.
*/
url: 'host.somewhere.com',
/*
The SFTP Port number supplied by the administrator of the external SFTP server (defaults to 22).
*/
port: 22,
/*
The transfer directory supplied by the administrator of the external SFTP server (optional).
*/
directory: 'transferfiles',
/*
RSA Host Key obtained via ssh-keyscan tool.

$ ssh-keyscan -t rsa -p 22 host.somewhere.com
AATpn1P9jB+cQx9Jq9UeZjA1245X7SBDcRiKh+Sok56VzSw==
*/
hostKey: "AATpn1P9jB+cQx9Jq9UeZjA1245X7SBDcRiKh+Sok56VzSw=="
});

/*
Creating a simple file.
*/
var myFileToUpload = file.create({
name: 'originalname.js',
fileType: file.Type.PLAINTEXT,
contents: 'I am a test file. Hear me roar.'
});

/*
Uploading the file to the external SFTP server.
*/
connection.upload({
/*
Subdirectory within the transfer directory specified when connecting (optional).
*/
directory: 'relative/path/to/remote/dir',
/*
Alternate file name to use instead of the one given to the file object (optional).
*/
filename: 'newFileNameOnServer.js',
/*
The file to upload.
*/
file: myFileToUpload,
/*
If a file already exists with that name, replace it instead of failing the upload.
*/
replaceExisting: true
});

var downloadedFile = connection.download({
/*
Subdirectory within the transfer directory specified when connecting (optional).
*/
directory: 'relative/path/to/file',
/*
The name of the file within the above directory on the external SFTP server which to download.
*/
filename: 'downloadMe.js'
});

});

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_4855409350.html