Archiver Object Members in SuiteScript for File Compression
The Archiver object in SuiteScript allows server scripts to manage file archiving efficiently with customizable methods.
The Archiver object in SuiteScript enables the creation and management of archive files through specific methods. This object is particularly useful for developers looking to package files for easier storage and transfer.
What Is the Archiver Object?
The Archiver object is part of the N/compress module, designed to facilitate the creation of archive files. You can utilize it by invoking the compress.createArchiver() method. This powerful feature allows server scripts to manage file archiving effectively.
Available Methods
The Archiver object includes two primary methods that enable file management:
Archiver.add(options)
-
Return Type/Value Type:
void -
Supported Script Types: Server scripts
-
Description: This method adds a file to the archive. The path for the target file can be specified using
options.directory. If not specified, the file is placed in the root directory of the archive.suitescript1// Add additional code2var archiver = compress.createArchiver();3archiver.add({4 file: myJpegFile,5 directory: 'pics/'6});7archiver.add({8 file: myTxtFile9});10// Add additional code
Archiver.archive(options)
- Return Type/Value Type:
[file.File] - Supported Script Types: Server scripts
- Description: This method creates an archive from the added files and returns a temporary file object representing the archive.
Error Handling
When using the Archiver methods, be aware of the following error codes:
COMPRESS_API_DUPLICATE_PATH: Triggered when a file has already been added using the same target path.COMPRESS_API_FILE_IS_TOO_LARGE: Triggered if the file exceeds size limits; maximum for standard files is 680MB, while binary/ASCII files can be up to 2GB.
Key Considerations
- Ensure you manage paths correctly to avoid the duplicate path error.
- Monitor file sizes to prevent compression failures.
Who This Affects
- Developers: Using suite scripts for automating file archiving processes.
- Administrators: Responsible for overseeing script functionality and managing scripts in the NetSuite environment.
Key Takeaways
- The Archiver object provides a streamlined way to manage file compression in SuiteScript.
- Understanding options for file paths can prevent common errors during compression.
- Monitoring file sizes is crucial for successful archiving processes.
Frequently Asked Questions (4)
How can I specify a directory for a file when adding it to an archive using the Archiver object?
What should I do to prevent the COMPRESS_API_DUPLICATE_PATH error?
What file size limits should I be aware of when using the Archiver object for compression?
Can the Archiver object be used in client-side scripts?
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