> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# zipCompress

> 将文件或文件夹压缩为 ZIP、TAR、JAR 或 GZIP 存档。

export const siteNameShort = "知行之桥";

将文件或文件夹压缩到存档中。要压缩单个文件，请使用 `includefile#`。要压缩文件夹，请使用 `includefolder#`。

## 必需的参数

* **type**: 存档的类型。允许的值为 ZIP、TAR、JAR 和 GZIP。默认值为 ZIP。
* **archive**: 磁盘上的路径（包括文件名），运算器应将存档放置在此处。
* **includefile#**: 要包含在存档中的文件数组。例如，要归档两个文件，请在 `includefile#1` 和 `includefile#2` 中将文件路径设置为这些文件。有关 {siteNameShort}Script 中数组属性的更多信息，请参阅 [ArcScript 简介](./operations)。
* **includefolder#**: 要包含在存档中的文件夹数组。例如，要归档两个文件夹，请在 `includefolder#1` 和 `includefolder#2` 中将文件路径设置为这些文件夹。

## 可选的参数

* **manifest**: 清单文件的位置。仅对 JAR 存档有效。

## 输出属性

* **zip:result**: 如果运算器成功，将返回 SUCCESS。

## 示例

此示例压缩两个文件夹（`/tmp/foo` 和 `/tmp/bar`），并将它们放入位于 `/home/mydata.gzip` 的 gzip 存档中。

```xml theme={null}
<!-- Creating the input item and the necessary attributes -->
<arc:set attr="zip.archive" value="/home/mydata.gzip" />
<arc:set attr="zip.type" value="GZIP" />
<arc:set attr="zip.includefolder#1" value="/tmp/foo" />
<arc:set attr="zip.includefolder#2" value="/tmp/bar" />

<arc:call op="zipCompress" in="zip">
  <!-- Optional logging step to log the status of the operation to the application log. -->
  <arc:set attr="_log.info" value="The zipCompress operation for connector [ConnectorId] has finished with a status of [results.zip:result]." />
</arc:call>
```
