Compression Module Reference | MuleSoft Documentation
# Compression Module Reference
Compression Module v2.2
A module which provides functionality for compressing and decompressing data.
Release Notes: Compression Module Release Notes
## Configurations
### Config
Default configuration
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
The name for this configuration. Connectors reference the configuration with this name.  
## Operations
### Archive
`<compression:archive>`
Compresses all the given entries into a new file in the configured format.
Each entry passed to this operation is placed inside the compressed archive with the entry name you provide in the DataWeave script. For example, for the following expression:
`{ file: vars.aTxtContent, 'dir/resume.pdf': vars.pdf }`
The resultant archive contains two entries: `file`, located at the root level, and `resume.pdf`, located in the `dir` directory.
`+- Archive | \- file1 | \+ dir1 | \- file2`
In this example, the slash `/` in the name of an entry indicates a directory separation. All names create directories inside the archive.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Entries to add to the archive file. | `#[payload]`  
Archiver |  | Archiver strategy that compresses multiple entries into an archive.  
Output Mime Type | MIME type of the payload that this operation outputs.  
Output Encoding | Encoding of the payload that this operation outputs.  
Streaming Strategy | 
  * Repeatable In Memory Stream
  * Repeatable File Store Stream
  * Non-repeatable Stream

| Configures how Mule processes streams. Repeatable streams are the default behavior.  
Target Variable | Name of the variable that stores the operation’s output.  
Target Value | Expression that evaluates the operation’s output. The expression outcome is stored in the target variable. | `#[payload]`  
#### Throws
  * COMPRESSION:COULD_NOT_COMPRESS


### Compress
`<compression:compress>`
Compresses a given content using the configured format `Zip` or `GZip`.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Content to compress. | `#[payload]`  
Compressor |  One of:
  * gzip-compressor
  * 
| Compressor strategy that compresses a file or a single-entry archive.  
Output Mime Type | MIME type of the payload that this operation outputs.  
Output Encoding | Encoding of the payload that this operation outputs.  
Streaming Strategy | 
  * Repeatable In Memory Stream
  * Repeatable File Store Stream
  * Non-repeatable Stream

| Configures how Mule processes streams. Repeatable streams are the default behavior.  
Target Variable | Name of the variable that stores the operation’s output.  
Target Value | Expression that evaluates the operation’s output. The expression outcome is stored in the target variable. | `#[payload]`  
#### Throws
  * COMPRESSION:COULD_NOT_COMPRESS


### Decompress
`<compression:decompress>`
Decompresses a single entry of compressed content in the configured format of `Zip` or `GZip`. Compressed archives can have multiple entries. The **Decompress** operation manages only single-entry archives because if the archive contains more than one entry, the operation does not know which entry to return. For multiple entry archives, use this module’s **Extract** operation, which enables you to select only formats that accept multiple entries.
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Compressed | Content to decompress. | `#[payload]`  
Decompressor |  One of:
  * gzip-decompressor
  * zip-decompressor

| Decompressor strategy that decompress a file or a single-entry archive.  
Output Mime Type | MIME type of the payload that this operation outputs.  
Output Encoding | Encoding of the payload that this operation outputs.  
Streaming Strategy | 
  * Repeatable In Memory Stream
  * Repeatable File Store Stream
  * Non-repeatable Stream

| Configures how Mule processes streams. Repeatable streams are the default behavior.  
Target Variable | Name of the variable that stores the operation’s output.  
Target Value | Expression that evaluates the operation’s output. The expression outcome is stored in the target variable. | `#[payload]`  
#### Throws
  * COMPRESSION:COULD_NOT_DECOMPRESS
  * COMPRESSION:INVALID_ARCHIVE
  * COMPRESSION:TOO_MANY_ENTRIES


### Extract
`<compression:extract>`
Decompresses a given content that represent an archive in a compression format. 
#### Parameters
Name | Type | Description | Default Value | Required  
---|---|---|---|---  
Compressed | Compressed archive content to decompress. | #[payload]  
Extractor |  One of:
  * zip-extractor

| Extractor strategy that decompresses an archive with multiple entries that are compressed in a particular format.  
Streaming Strategy | 
  * Repeatable In Memory Stream
  * Repeatable File Store Stream
  * Non-repeatable Stream

| Configures how Mule processes streams. Repeatable streams are the default behavior.  
Target Variable | Name of the variable that stores the operation’s output.  
Target Value | Expression that evaluates the operation’s output. The expression outcome is stored in the target variable. | `#[payload]`  
#### Throws
  * COMPRESSION:COULD_NOT_DECOMPRESS
  * COMPRESSION:INVALID_ARCHIVE


## Types
### Repeatable In Memory Stream
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Initial Buffer Size | This is the amount of memory to allocate to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then the buffer expands according to the bufferSizeIncrement attribute, with an upper limit of maxInMemorySize.  
Buffer Size Increment | This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower will mean that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error will be raised when the buffer gets full.  
Max Buffer Size | This is the maximum amount of memory that will be used. If more than that is used then a STREAM_MAXIMUM_SIZE_EXCEEDED error will be raised. A value lower or equal to zero means no limit.  
Buffer Unit |  Enumeration, one of: | The unit in which all these attributes are expressed  
### Repeatable File Store Stream
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Max In Memory Size | Defines the maximum memory that the stream should use to keep data in memory. If more than that is consumed then it will start to buffer the content on disk.  
Buffer Unit |  Enumeration, one of: | The unit in which maxInMemorySize is expressed  
### Non-repeatable Stream
Disables the repeatable stream functionality and uses non-repeatable streams to have less performance overhead, memory use, and cost.
### Zip Compressor
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Force Zip64 | Enables you to compress files and byte arrays greater than 4 GB.  
### Zip Archiver
Field | Type | Description | Default Value | Required  
---|---|---|---|---  
Force Zip64 | Enables you to archive files and byte arrays greater than 4 GB.  
## See Also
MuleSoft Help Center