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.
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 Name | Type | Return Type / Value Type | Supported Script Types | Description |
|---|---|---|---|---|
compress.Archiver | Object | - | Server scripts | Functionality to create archive files. |
compress.createArchiver() | Method | compress.Archiver | Server scripts | Creates a compress.Archiver object. |
compress.gunzip(options) | Method | file.File | Server scripts | Decompresses a file to a temporary file object. |
compress.gzip(options) | Method | file.File | Server scripts | Compresses a file to a temporary file object. |
compress.Type | Enum | enum | Server scripts | Holds 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:
// Example of creating an Archiver objectvar 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 andgunzip()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?
What script types support the N/compress module's methods?
How can I create an Archiver object using the N/compress module?
What file formats does the N/compress module support for compression?
Was this article helpful?
More in Platform
- Style Object Members for Workbook API in NetSuite
The Style object provides customizable properties for workbook formatting in NetSuite, enhancing report and visualization functionality.
- Asynchronous HTTP Requests with SuiteScript Promises
Use SuiteScript to send asynchronous HTTP requests with promises for efficient error handling and response processing.
- Setting Sublist Field Values in SuiteScript
Set values for sublist fields in SuiteScript using the setSublistValue method. Understand required parameters and error handling.
- In This Help Topic
Explore N/log module guidelines, log levels, and script execution logs for efficient logging in SuiteScript.
Advertising
Reach Platform Professionals
Put your product in front of NetSuite experts who work with Platform every day.
Sponsor This Category