Connection Object Members Management in SuiteScript
The Connection Object Members in SuiteScript facilitate file management on SFTP servers via methods for uploading, downloading, and directory management.
The Connection Object Members in SuiteScript enable developers to efficiently manage file transfers and directories on SFTP servers. Using the N/sftp module, these methods cover various functionalities like uploading, downloading, and organizing files in a remote directory.
What Are Connection Object Members?
The Connection Object Members are methods and enumerations you can call on the sftp.Connection object within the N/sftp module. These members allow you to interact with an SFTP server programmatically, providing a streamlined approach to file management.
Key Functionalities of Connection Object Members
The following methods are available 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. |
| Method | Connection.upload(options) | void | Server scripts | Uploads a file to the remote FTP server. |
| Method | Connection.makeDirectory(options) | string | Server scripts | Creates an empty directory. |
| Method | Connection.removeDirectory(options) | void | Server scripts | Removes an empty directory. |
| Method | Connection.removeFile(options) | void | Server scripts | Removes a file in a directory. |
| Method | Connection.move(options) | void | Server scripts | Moves a file or directory from one location to another. |
| Method | Connection.list(options) | Array<Object> | Server scripts | Lists items in the remote directory. |
| Enum | Connection.MAX_FILE_SIZE | enum | Server scripts | Holds the values for the maximum file size. |
| Enum | Connection.MAX_TRANSFER_TIMEOUT | enum | Server scripts | Holds the values for the maximum transfer timeout. |
Important Notes on Using Connection Object Members
- Escaping Wildcards: All paths, directories, and filenames with wildcards like
?and*must have those characters escaped unless they are specifically intended to function as wildcards. This is crucial for ensuring accurate file operation commands. - SSH Key Requirements: Establish an SFTP connection using SSH keys. These keys must be uploaded through NetSuite's secure interface, capturing necessary permissions. For key management tasks, refer to the N/keyControl module for effective handling.
Related Functionalities
While the Connection Object Members focus on file management, other aspects of SFTP in NetSuite can be achieved using:
- RESTlets: For data transfer without SFTP, RESTlets can manage file uploads and downloads.
- SOAP Web Services: These allow CRUD operations on file records, facilitating direct interaction with the File Cabinet.
Conclusion
The Connection Object Members in SuiteScript provide a structured method for managing SFTP file operations with methods for uploading, downloading, and directory management, making file interactions programmatically efficient.
Key Takeaways
- Connection Object Members simplify SFTP operations such as upload/download.
- Escaping wildcards is necessary for file path accuracy.
- SSH keys are required for secure SFTP connections and must be managed through NetSuite.
- RESTlets and SOAP Web Services offer alternatives for file operations without SFTP.
Frequently Asked Questions (4)
Which script types support the methods on the sftp.Connection object?
Do I need to upload SSH keys separately when using Connection Object Members?
How should I handle wildcards in file paths when using Connection Object Members?
Can Connection Object Members be used for file operations other than SFTP in NetSuite?
Was this article helpful?
More in SuiteScript
- SuiteScript 2.1 Enhancements in NetSuite February Updates
SuiteScript 2.1 now supports async features and PATCH method. Discover the latest API and SuiteProcurement improvements.
- Scheduling Map/Reduce Script Deployments in NetSuite
Learn to schedule map/reduce script submissions, including one-time and recurring options in NetSuite.
- Binary File Support in N/https Module for SuiteScript
SuiteScript enhances capabilities with binary file support in the N/https module, allowing improved data handling in external communications.
- API Governance Units Calculation in NetSuite 2026.1
NetSuite 2026.1 introduces examples illustrating API governance unit calculations for both user event and scheduled scripts.
