---
schema_version: "1"
id: f873c027e9ae692ce1870bddc3fa365998dafe7739370f537be2cc75783580ec
title: Compression Module Reference
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/compression-module/2.0/compression-documentation.md
canonical_url: https://docs.mulesoft.com/compression-module/2.0/compression-documentation
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 295726723e1598a3285639d98c5bd9316783dcc1e53f8f8d64291c212a95730b
description: MuleSoft Documentation Site
release: "2.0"
latest: false
---
---
product: Compression Module
version: 2.0
---

# Compression Module Reference

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Compression Module v2.1

A module which provides functionality for compressing and decompressing data.

Release Notes:
[Compression Module Release Notes](https://docs.mulesoft.com/release-notes/mule-runtime/module-compression)

## Configurations

---

### Config

Default configuration

#### Parameters

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Name</p></td><td><p>String</p></td><td><p>The name for this configuration. Connectors reference the configuration with this name.</p></td><td></td><td><p>x</p></td></tr></tbody></table>

## 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 name provided
by the user in the DataWeave script. For example, for this expression:

`{ file: vars.aTxtContent, 'dir/resume.pdf': vars.pdf }`

The resultant archive contains two entries one named "file" at root level and another called
"resume.pdf" inside a directory called "dir"

`- Archive | \- file1 | \ dir1 | \- file2`

In this example, the slash "/" in the name of an entry indicates directory separation, so all names
are introspected to create directories inside the archive.

#### Parameters

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Entries</p></td><td><div><div><p>Object</p></div></div></td><td></td><td><p>#[payload]</p></td><td></td></tr><tr><td><p>Archiver</p></td><td><div><div><p>zip-archiver</p></div></div></td><td></td><td></td><td><p>x</p></td></tr><tr><td><p>Output Mime Type</p></td><td><div><div><p>String</p></div></div></td><td><p>The MIME type of the payload that this operation outputs.</p></td><td></td><td></td></tr><tr><td><p>Output Encoding</p></td><td><div><div><p>String</p></div></div></td><td><p>The encoding of the payload that this operation outputs.</p></td><td></td><td></td></tr><tr><td><p>Streaming Strategy</p></td><td><div><div><ul><li><p><a href="#repeatable-in-memory-stream">Repeatable In Memory Stream</a></p></li><li><p><a href="#repeatable-file-store-stream">Repeatable File Store Stream</a></p></li><li><p>non-repeatable-stream</p></li></ul></div></div></td><td><p>Configure if repeatable streams should be used and their behavior.</p></td><td></td><td></td></tr><tr><td><p>Target Variable</p></td><td><div><div><p>String</p></div></div></td><td><p>The name of a variable on which the operation's output will be placed</p></td><td></td><td></td></tr><tr><td><p>Target Value</p></td><td><div><div><p>String</p></div></div></td><td><p>An expression to evaluate against the operation's output and the outcome of that expression will be stored in the target variable.</p></td><td><p>#[payload]</p></td><td></td></tr></tbody></table>

#### Output

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Type</strong></p></td><td><div><div><p>Binary</p></div></div></td></tr></tbody></table>

#### Throws

- COMPRESSION:COULD\_NOT\_COMPRESS

### Compress

`<compression:compress>`

Compresses a given content using the configured format, ZIP or GZIP. If a problem occur while
compressing the content a COULD\_NOT\_COMPRESS error will be thrown.

#### Parameters

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Content</p></td><td><div><div><p>Binary</p></div></div></td><td></td><td><p>#[payload]</p></td><td></td></tr><tr><td><p>Compressor</p></td><td><div><div><p>One of:</p></div><div><ul><li><p>gzip-compressor</p></li><li><p>zip-compressor</p></li></ul></div></div></td><td></td><td></td><td><p>x</p></td></tr><tr><td><p>Output Mime Type</p></td><td><div><div><p>String</p></div></div></td><td><p>The MIME type of the payload that this operation outputs.</p></td><td></td><td></td></tr><tr><td><p>Output Encoding</p></td><td><div><div><p>String</p></div></div></td><td><p>The encoding of the payload that this operation outputs.</p></td><td></td><td></td></tr><tr><td><p>Streaming Strategy</p></td><td><div><div><ul><li><p><a href="#repeatable-in-memory-stream">Repeatable In Memory Stream</a></p></li><li><p><a href="#repeatable-file-store-stream">Repeatable File Store Stream</a></p></li><li><p>non-repeatable-stream</p></li></ul></div></div></td><td><p>Configure if repeatable streams should be used and their behavior</p></td><td></td><td></td></tr><tr><td><p>Target Variable</p></td><td><div><div><p>String</p></div></div></td><td><p>The name of a variable on which the operation's output will be placed</p></td><td></td><td></td></tr><tr><td><p>Target Value</p></td><td><div><div><p>String</p></div></div></td><td><p>An expression that will be evaluated against the operation's output and the outcome of that expression will be stored in the target variable</p></td><td><p>#[payload]</p></td><td></td></tr></tbody></table>

#### Output

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Type</strong></p></td><td><div><div><p>Binary</p></div></div></td></tr></tbody></table>

#### Throws

- COMPRESSION:COULD\_NOT\_COMPRESS

### Decompress

`<compression:decompress>`

Decompresses a single entry of compressed content which is assumed to be in an specific format (ZIP
or GZIP). If the content is not in the configured format, an INVALID\_ARCHIVE error is thrown.
Compressed archives can have multiple entries, this operation can handle only single entry archives
because if the archive would contain more than one the operation wouldn't know which should return,
if the content has more than one entry an TOO\_MANY\_ENTRIES error will be thrown. For multiple
entry archives use the \`extract\` operation of this module, which will let you choose only formats
that accept multiple entries.

#### Parameters

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Compressed</p></td><td><div><div><p>Binary</p></div></div></td><td></td><td><p>#[payload]</p></td><td></td></tr><tr><td><p>Decompressor</p></td><td><div><div><p>One of:</p></div><div><ul><li><p>gzip-decompressor</p></li><li><p>zip-decompressor</p></li></ul></div></div></td><td></td><td></td><td><p>x</p></td></tr><tr><td><p>Output Mime Type</p></td><td><div><div><p>String</p></div></div></td><td><p>The MIME type of the payload that this operation outputs.</p></td><td></td><td></td></tr><tr><td><p>Output Encoding</p></td><td><div><div><p>String</p></div></div></td><td><p>The encoding of the payload that this operation outputs.</p></td><td></td><td></td></tr><tr><td><p>Streaming Strategy</p></td><td><div><div><ul><li><p><a href="#repeatable-in-memory-stream">Repeatable In Memory Stream</a></p></li><li><p><a href="#repeatable-file-store-stream">Repeatable File Store Stream</a></p></li><li><p>non-repeatable-stream</p></li></ul></div></div></td><td><p>Configure if repeatable streams should be used and their behavior</p></td><td></td><td></td></tr><tr><td><p>Target Variable</p></td><td><div><div><p>String</p></div></div></td><td><p>The name of a variable on which the operation's output will be placed</p></td><td></td><td></td></tr><tr><td><p>Target Value</p></td><td><div><div><p>String</p></div></div></td><td><p>An expression that will be evaluated against the operation's output and the outcome of that expression will be stored in the target variable</p></td><td><p>#[payload]</p></td><td></td></tr></tbody></table>

#### Output

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Type</strong></p></td><td><div><div><p>Binary</p></div></div></td></tr></tbody></table>

#### 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

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Compressed</p></td><td><div><div><p>Binary</p></div></div></td><td></td><td><p>#[payload]</p></td><td></td></tr><tr><td><p>Extractor</p></td><td><div><div><p>One of:</p></div><div><ul><li><p>zip-extractor</p></li></ul></div></div></td><td></td><td></td><td><p>x</p></td></tr><tr><td><p>Streaming Strategy</p></td><td><div><div><ul><li><p><a href="#repeatable-in-memory-stream">Repeatable In Memory Stream</a></p></li><li><p><a href="#repeatable-file-store-stream">Repeatable File Store Stream</a></p></li><li><p>non-repeatable-stream</p></li></ul></div></div></td><td><p>Configure if repeatable streams should be used and their behavior</p></td><td></td><td><p>&nbsp;</p></td></tr><tr><td><p>Target Variable</p></td><td><div><div><p>String</p></div></div></td><td><p>The name of a variable on which the operation's output will be placed</p></td><td></td><td></td></tr><tr><td><p>Target Value</p></td><td><div><div><p>String</p></div></div></td><td><p>An expression that will be evaluated against the operation's output and the outcome of that expression will be stored in the target variable</p></td><td><p>#[payload]</p></td><td></td></tr></tbody></table>

#### Output

<table><colgroup><col> <col></colgroup><tbody><tr><td><p><strong>Type</strong></p></td><td><div><div><p>Object</p></div></div></td></tr></tbody></table>

#### Throws

- COMPRESSION:COULD\_NOT\_DECOMPRESS

- COMPRESSION:INVALID\_ARCHIVE

## Types

### Repeatable In Memory Stream

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Initial Buffer Size</p></td><td><div><div><p>Number</p></div></div></td><td><p>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.</p></td><td></td><td></td></tr><tr><td><p>Buffer Size Increment</p></td><td><div><div><p>Number</p></div></div></td><td><p>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.</p></td><td></td><td></td></tr><tr><td><p>Max Buffer Size</p></td><td><div><div><p>Number</p></div></div></td><td><p>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.</p></td><td></td><td></td></tr><tr><td><p>Buffer Unit</p></td><td><div><div><p>Enumeration, one of:</p></div><div><ul><li><p>BYTE</p></li><li><p>KB</p></li><li><p>MB</p></li><li><p>GB</p></li></ul></div></div></td><td><p>The unit in which all these attributes are expressed</p></td><td></td><td></td></tr></tbody></table>

### Repeatable File Store Stream

<table><colgroup><col> <col> <col> <col> <col></colgroup><thead><tr><th>Field</th><th>Type</th><th>Description</th><th>Default Value</th><th>Required</th></tr></thead><tbody><tr><td><p>Max In Memory Size</p></td><td><div><div><p>Number</p></div></div></td><td><p>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.</p></td><td></td><td></td></tr><tr><td><p>Buffer Unit</p></td><td><div><div><p>Enumeration, one of:</p></div><div><ul><li><p>BYTE</p></li><li><p>KB</p></li><li><p>MB</p></li><li><p>GB</p></li></ul></div></div></td><td><p>The unit in which maxInMemorySize is expressed</p></td><td></td><td></td></tr></tbody></table>

## See Also

[Salesforce Help](https://help.salesforce.com)
