Archiver.archive(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Creates an archive with the added files and returns it as a temporary file object.

Returns

file.File

Supported Script Types

Server scripts

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

Governance

None

Module

N/compress Module

Parent Object

compress.Archiver

Sibling Object Members

Archiver Object Members

Since

2020.2

Parameters

Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.name

string

required

The name of the archive file.

options.type

string

optional

The archive type. See the compress.Type enum.

This parameter does not need to be specified if options.name has one of the following extensions:

  • .cpio

  • .tar

  • .tar.gz

  • .tar.bz2

  • .tgz

  • .tbz2

  • .zip

Errors

Error Code

Thrown If

COMPRESS_API_UNSUPPORTED_ARCHIVE_TYPE

The options.type parameter is an invalid archive type.

COMPRESS_API_UNRECOGNIZED_ARCHIVE_FILE_EXTENSION

The options.type parameter is not specified and the archive type cannot be determined.

COMPRESS_API_UNABLE_TO_RETRIEVE_FILE_CONTENTS

The contents cannot be retrieved for any of the files to be archived.

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/compress Module Script Sample.

            // Add additional code
...
var archiver = compress.createArchiver();
archiver.add({
    file: binaryFile
});
archiver.add({
    file: textFile,
    directory: 'txt/'
});

var zipFile = archiver.archive({
    name: 'myarchive.zip'
});
var tgzFile = archiver.archive({
    name: 'myarchive.tar.gz'
});...
// Add additional code 

          

Related Topics

compress.Archiver
N/compress Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices