Skip to content

Archive

Create and extract ZIP, TAR, and gzip archives.

6 modules

ModuleDescription
Gunzip 解壓縮解壓縮 gzip 壓縮檔案
Gzip 壓縮使用 gzip 壓縮單一檔案
建立 TAR 壓縮檔建立具備選擇性 gzip/bz2/xz 壓縮的 TAR 壓縮檔
解壓 TAR 封存從 TAR 封存中解壓檔案(自動偵測壓縮)
建立 ZIP 壓縮檔從檔案列表建立 ZIP 壓縮檔
解壓縮 ZIP 壓縮檔從 ZIP 壓縮檔中解壓縮檔案

Modules

Gunzip 解壓縮

archive.gunzip

解壓縮 gzip 壓縮檔案

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-gzip 壓縮檔案的路徑
output_pathstringNo-解壓縮後檔案的路徑(預設為輸入路徑去除 .gz 副檔名)

Output:

FieldTypeDescription
pathstring解壓縮後檔案的路徑
sizenumber解壓縮後檔案大小(位元組)

Example: Decompress a gzip file

yaml
input_path: /tmp/data.txt.gz

Gzip 壓縮

archive.gzip

使用 gzip 壓縮單一檔案

Parameters:

NameTypeRequiredDefaultDescription
input_pathstringYes-要壓縮的檔案路徑
output_pathstringNo-壓縮後檔案的路徑(預設為輸入路徑 + .gz)

Output:

FieldTypeDescription
pathstring壓縮後檔案的路徑
original_sizenumber原始檔案大小(位元組)
compressed_sizenumber壓縮後檔案大小(位元組)
rationumber壓縮比(壓縮後 / 原始)

Example: Compress a file with gzip

yaml
input_path: /tmp/data.txt

建立 TAR 壓縮檔

archive.tar_create

建立具備選擇性 gzip/bz2/xz 壓縮的 TAR 壓縮檔

Parameters:

NameTypeRequiredDefaultDescription
output_pathstringYes-輸出 TAR 檔案的路徑
filesarrayYes-要包含在壓縮檔中的檔案路徑列表
compressionselect (none, gzip, bz2, xz)Nogzip壓縮方法

Output:

FieldTypeDescription
pathstring建立的 TAR 檔案路徑
sizenumber封存大小(位元組)
file_countnumber封存中的檔案數量

Example: Create gzipped TAR archive

yaml
output_path: /tmp/archive.tar.gz
files: ["/tmp/file1.txt", "/tmp/file2.txt"]
compression: gzip

解壓 TAR 封存

archive.tar_extract

從 TAR 封存中解壓檔案(自動偵測壓縮)

Parameters:

NameTypeRequiredDefaultDescription
archive_pathstringYes-要解壓的 TAR 封存路徑
output_dirstringYes-要解壓檔案的目錄

Output:

FieldTypeDescription
extracted_filesarray已解壓檔案路徑列表
total_sizenumber已解壓檔案的總大小(位元組)

Example: Extract TAR.GZ archive

yaml
archive_path: /tmp/archive.tar.gz
output_dir: /tmp/extracted/

建立 ZIP 壓縮檔

archive.zip_create

從檔案列表建立 ZIP 壓縮檔

Parameters:

NameTypeRequiredDefaultDescription
output_pathstringYes-輸出 ZIP 檔案的路徑
filesarrayYes-要包含在壓縮檔中的檔案路徑列表
compressionselect (stored, deflated, bzip2, lzma)Nodeflated壓縮方法
passwordstringNo-可選的密碼以保護壓縮檔(僅限解壓縮,支援有限)

Output:

FieldTypeDescription
pathstring建立的 ZIP 檔案路徑
sizenumber壓縮檔大小(位元組)
file_countnumber壓縮檔中的檔案數量

Example: Create ZIP from files

yaml
output_path: /tmp/archive.zip
files: ["/tmp/file1.txt", "/tmp/file2.txt"]
compression: deflated

解壓縮 ZIP 壓縮檔

archive.zip_extract

從 ZIP 壓縮檔中解壓縮檔案

Parameters:

NameTypeRequiredDefaultDescription
archive_pathstringYes-要解壓縮的 ZIP 壓縮檔路徑
output_dirstringYes-解壓縮檔案的目錄
passwordstringNo-加密壓縮檔的密碼

Output:

FieldTypeDescription
extracted_filesarray解壓縮後的檔案路徑列表
total_sizenumber解壓縮後檔案的總大小(位元組)

Example: Extract ZIP archive

yaml
archive_path: /tmp/archive.zip
output_dir: /tmp/extracted/

Released under the Apache 2.0 License.