N/compress Module: File Compression Features in SuiteScript

The N/compress module in SuiteScript enables file compression and decompression, providing essential tools for file management.

·2 min read·View Oracle Docs

The N/compress module provides SuiteScript developers with critical functionality for compressing and decompressing files. This module is pivotal for managing file sizes, especially when handling multiple file uploads in NetSuite. With this capability, users can optimize storage and enhance performance by utilizing compressed file formats such as ZIP or TAR.

Overview of N/compress Module Members

The N/compress module comprises several key members, each serving a specific functionality. Below is a detailed description:

Member NameTypeReturn Type / Value TypeSupported Script TypesDescription
compress.ArchiverObject-Server scriptsFunctionality to create archive files.
compress.createArchiver()Methodcompress.ArchiverServer scriptsCreates a compress.Archiver object.
compress.gunzip(options)Methodfile.FileServer scriptsDecompresses a file to a temporary file object.
compress.gzip(options)Methodfile.FileServer scriptsCompresses a file to a temporary file object.
compress.TypeEnumenumServer scriptsHolds string values for archive types.

Detailed Method Descriptions

How to Create an Archiver Object

To initiate file compression or decompression, you must first create an Archiver object. This is done using the compress.createArchiver() method.

Example Syntax:

suitescript
// Example of creating an Archiver object
var archiver = compress.createArchiver();

Overview of Compress Methods

  • compress.gzip(options): This method takes options to define how the file should be compressed and returns a temporary file object containing the compressed file.

  • compress.gunzip(options): This method decompresses the specified file and returns it in a temporary file object, making it easy to use the uncompressed data immediately.

Conclusion

Utilizing the N/compress module effectively allows for efficient file handling and storage management within NetSuite, making it an essential tool in any SuiteScript developer's arsenal.

Source: This article is based on Oracle's official NetSuite documentation.

Key Takeaways

  • The N/compress module facilitates file compression, essential for managing storage.
  • Key methods include gzip() for compressing files and gunzip() for decompressing.
  • Use compress.createArchiver() to create an Archiver object for file management.

Frequently Asked Questions (4)

Do you need to enable a feature flag to use the N/compress module in SuiteScript?
The article does not specify any need to enable a feature flag to use the N/compress module. It appears to be available directly for use in server scripts.
What script types support the N/compress module's methods?
The N/compress module's methods, such as `compress.gzip()` and `compress.gunzip()`, are supported in server scripts.
How can I create an Archiver object using the N/compress module?
You can create an Archiver object by using the `compress.createArchiver()` method in your SuiteScript. This object is essential for initiating compression or decompression tasks.
What file formats does the N/compress module support for compression?
The N/compress module supports compressed file formats like ZIP or TAR, as indicated by the enum `compress.Type` which holds string values for archive types.
Source: N/compress Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Platform

View all Platform articles →