file.load(options)

Method Description

Loads an existing file from the NetSuite File Cabinet.

The file size limit for this method is 2GB.

Returns

file.File

Supported Script Types

Server scripts

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

Governance

10 units

Module

N/file Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.id

number | string

required

The identifier of a file in the File Cabinet.

To specify a file in the File Cabinet, you can pass one of the following as the value of this parameter:

  • The internal ID of the file as a number or string

  • The absolute file path to the file in the File Cabinet (for example, ‘Images/myImageFile.jpg’)

  • The relative file path to the file in the File Cabinet (for example, ‘./Images/myImageFile.jpg’ to specify a file path relative to the current folder of your script, or ‘../Images/myImageFile.jpg’ to specify a file path relative to the parent folder of your script)

To find the internal ID of the file in the UI, select Documents > Files > File Cabinet.

2015.2

Errors

Error Code

Message

Thrown If

INSUFFICIENT_PERMISSION

You do not have access to the media item you selected.

Internal ID passed is invalid.

RCRD_DSNT_EXIST

That record does not exist. path: {path}

Relative file path passed is invalid.

SSS_MISSING_REQD_ARGUMENT

<name of missing parameter>

A required argument is not passed.

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/file Module Script Samples.

          // Add additional code 
...
var fileObj = file.load({
    id: 'Images/myImageFile.jpg'
});
fileObj.description = 'my test file';
var fileId = fileObj.save();
...
// Add additional code 

        

Related Topics

General Notices