Managing File Compression with Archiver in SuiteScript
Utilize the Archiver object in SuiteScript for effective file compression, management, and avoiding errors.
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 SuiteScript
- Common SuiteScript Errors and Solutions for NetSuite
Common NetSuite script errors include INVALID_SCRIPT_DEPLOYMENT_ID and SSS_AUTHORIZATION_HEADER_NOT_ALLOWED. Learn effective solutions.
- Set Sublist Field Values in SuiteScript 2.x for Record Management
Set sublist field values in SuiteScript 2.x for effective record management using standard and dynamic modes.
- Setting Field Values in SuiteScript for Effective Record
Learn to set field values in SuiteScript effectively, troubleshooting common errors and understanding data types.
- SuiteScript 2.1 Enhancements and API Updates in NetSuite
SuiteScript 2.1 enables execution of 2.0 scripts and supports PATCH method for enhanced API capabilities.
Advertising
Reach SuiteScript Professionals
Put your product in front of NetSuite experts who work with SuiteScript every day.
Sponsor This Category