ServerResponse.writeFile(options)

Method Description

Writes a file to the response.

Textual files are re-encoded to UTF-8 by default. If you want to preserve the file's encoding, you must specify the same charset in the response's Content-Type header using ServerResponse.setHeader(options) before calling this method. To see an example, refer to Return a File with Alternative Character Encoding.

Returns

void

Supported Script Types

Server scripts

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

Governance

None

Module

N/https Module

Since

2015.2

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

Since

options.file

file.File

required

A file.File Object that encapsulates the file to be written.

2015.2

options.isInline

boolean

optional

Determines whether the field is inline. If true, the file is inline.

2015.2

Errors

Error Code

Message

Thrown If

SSS_MISSING_REQD_ARGUMENT

Missing a required argument: {param name}

The options.file parameter is not specified.

WRONG_PARAMETER_TYPE

{param name}

The value input for options.file is not a file.File Object.

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

          // Add additional code 
...
serverResponse.writeFile({
    file: myFileObj,
    isInline: true
});
...
// Add additional code 

        

Related Topics

General Notices