Connection.upload(options)
|
Method Description |
Uploads a file to the remote FTP server. The maximum file size that can be uploaded to is 100 MB. |
|
Returns |
void |
|
Supported Script Types |
Server scripts For more information, see SuiteScript 2.x Script Types. |
|
Governance |
100 units |
|
Module |
|
|
Since |
2016.2 |
Parameters
The options parameter is a JavaScript object.
|
Parameter |
Type |
Required / Optional |
Description |
Since |
|---|---|---|---|---|
|
|
required |
The file to upload. |
2016.2 |
|
|
|
string |
optional |
The name to give the uploaded file on server. By default, the filename is the same specified by
Note:
Illegal characters are automatically escaped. |
2016.2 |
|
|
string |
optional |
The relative path to the directory where the file should be upload to. By default, the path is set to the current directory.
Important:
This input must take the form of a relative path. |
2016.2 |
|
|
number |
optional |
The number of seconds to allow for the file to upload. By default, this value is set to 300 seconds.
Important:
This parameter does not specify the overall timeout limit. The value is only applied when no data is received within the specified period. |
2016.2 |
|
|
boolean |
optional |
Indicates whether the file being uploaded should overwrite any file with the name If false, the FTP_FILE_ALREADY_EXISTS exception is thrown when a file with the same name already exists in the By default, this value is false. |
2016.2 |
Errors
|
Error Code |
Thrown If |
|---|---|
|
|
The file or directory does not exist. |
|
|
The transfer is taking longer than the specified options.timeout value. |
|
|
The options.timeout value is either a negative value, zero or greater than 300 seconds. |
|
|
The options.replaceExisting value is false and a file with the same name exists in the remote directory. The error is also thrown when the SFTP server doesn't support the STAT command and instead requires the LIST command. To enable the LIST command, see SFTP: Use LIST to Test That a File Exists preference in Setting General Account Preferences. |
|
|
The connection was reset. |
|
|
The file’s remote path is invalid. |
|
|
The connection was closed by the host. |
|
|
Access to the file or directory on the remote FTP server was denied. |
Syntax
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
...
objConnection.upload({
directory: 'relative/path/to/remote/dir',
filename: 'newFileNameOnServer',
file: myFileToUpload,
replaceExisting: true
});
...
//Add additional code