File.getContents()

Method Description

Method used to return the content of the file.

Important:

Content held in memory is limited to 10MB.

Note:

You can access CSV or text files (including files over 10MB) using File.appendLine(options) or File.lines.iterator().

Returns

The file content as a string.

Supported Script Types

Server scripts

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

Governance

None

Module

N/file Module

Since

2015.2

Errors

Error Code

Message

Thrown If

SSS_FILE_CONTENT_SIZE_EXCEEDED

The file content you are attempting to access exceeds the maximum allowed size of 10 MB.

You attempt to return the content of a file larger than 10MB.

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: 145
});
if (fileObj.size < 10485760){
    fileObj.getContents();
    }
...
//Add additional code 

        

Related Topics

General Notices