Articles in this section

ZIP Archive Integration in FlowMattic

Updated:

The ZIP Archive app is a built-in FlowMattic application that lets you create, extract, inspect, and modify ZIP archives from file URLs — with automatic WordPress Media Library integration. No external connection or API key is required.


Overview

The ZIP Archive app enables you to bundle files into ZIP archives, extract contents from existing archives, inspect archive contents, and add or remove files — all within your automated workflows. Created and extracted files are automatically uploaded to the WordPress Media Library.


Connection Setup

The ZIP Archive is a core utility app — no connection setup is needed.

  • No API key required
  • No external service to configure
  • Available immediately in all FlowMattic installations
  • Requires PHP’s ZipArchive extension (included in PHP 5.3+)

Simply select ZIP Archive when adding an action step to your workflow.


Available Actions

The ZIP Archive app provides 5 actions for working with ZIP files.

zip archive integration actions.png

1. Create ZIP Archive

Create a new ZIP archive from file URLs and save it to the WordPress Media Library.

Configuration:

Field Required Description
File URLs Yes File URLs to include. Accepts comma-separated URLs, JSON array of strings, or JSON array of objects with a url key.
Archive Name Yes Name for the ZIP file. The .zip extension is added automatically if not provided.
Base Folder No Optional folder name inside the ZIP to place all files into. Leave empty to add files to the root.

Supported Input Formats for File URLs:

# Comma-separated
https://example.com/file1.pdf, https://example.com/file2.jpg

# JSON array of strings
["https://example.com/file1.pdf", "https://example.com/file2.jpg"]

# JSON array of objects
[{"url": "https://example.com/file1.pdf"}, {"url": "https://example.com/file2.jpg"}]

Output:

Field Description
status success or error
media_id WordPress Media Library attachment ID
media_url URL to the created ZIP file
file_name Name of the ZIP file
file_count Number of files in the archive
file_size Human-readable file size (e.g., “2.5 MB”)
file_size_bytes File size in bytes
files_added Array of file names added to the archive
failed_files Array of files that failed to download (with error details)

create zip archive action.png

Tip: Use the PHP Array > Convert to List action to generate a comma-separated URL list from an array of file URLs.


2. Extract ZIP Archive

Extract files from a ZIP archive and save them to the WordPress Media Library.

Configuration:

Field Required Description
ZIP File URL Yes URL of the ZIP file to extract.
Password No Password if the ZIP is password-protected. Leave empty for unprotected archives.

Output:

Field Description
status success or error
total_files Number of files extracted
extracted_files Array of extracted files with file_name, relative_path, media_id, and media_url

Each extracted file contains:

Field Description
file_name Name of the extracted file
relative_path Original path inside the ZIP archive
media_id WordPress Media Library attachment ID
media_url URL to the extracted file
error Error message if extraction failed for this file

extract zip archive.png

Note: Extracted files are automatically uploaded to the WordPress Media Library. File types must comply with WordPress upload settings.


3. List ZIP Contents

Inspect all files and folders inside a ZIP archive without extracting it.

Configuration:

Field Required Description
ZIP File URL Yes URL of the ZIP file to inspect.

Output:

Field Description
status success or error
total_entries Number of entries in the archive
total_size Total uncompressed size (human-readable)
total_size_bytes Total uncompressed size in bytes
total_compressed_size Total compressed size (human-readable)
total_compressed_size_bytes Total compressed size in bytes
compression_ratio Compression percentage (e.g., “21.0%”)
files Array of file/folder entries

Each entry in the files array contains:

Field Description
name File or folder path
size Uncompressed size (human-readable)
size_bytes Uncompressed size in bytes
compressed_size Compressed size (human-readable)
compressed_size_bytes Compressed size in bytes
modified Last modification timestamp
is_directory true for directories, false for files

Use Case: Inspect archive contents before extracting, or use the file paths from this action with the “Remove Files from ZIP” action.


4. Add Files to ZIP

Add new files to an existing ZIP archive.

Configuration:

Field Required Description
ZIP File URL Yes URL of the existing ZIP archive.
File URLs to Add Yes File URLs to add. Same formats as Create ZIP Archive.
Base Folder No Optional folder name inside the ZIP to place the new files into.

Output:

Field Description
status success or error
media_id WordPress Media Library attachment ID
media_url URL to the updated ZIP file
file_name Name of the ZIP file
total_files Updated total file count
files_added Array of file names that were added
failed_files Array of files that failed to download

Note: The existing archive contents are preserved — new files are appended to the archive.


5. Remove Files from ZIP

Remove specific files from an existing ZIP archive.

Configuration:

Field Required Description
ZIP File URL Yes URL of the ZIP archive.
File Names to Remove Yes Comma-separated list of file paths to remove. Use exact paths as shown in the List ZIP Contents action.

Output:

Field Description
status success or error
media_id WordPress Media Library attachment ID
media_url URL to the updated ZIP file
file_name Name of the ZIP file
total_files Updated total file count
files_removed Array of file paths that were removed
not_found Array of file paths that were not found in the archive

Example:

If List ZIP Contents shows these files:

documents/report.pdf
images/photo.jpg
readme.txt

Then File Names to Remove should be:

documents/report.pdf, images/photo.jpg

Important: File paths are case-sensitive and must match exactly as shown in the List ZIP Contents output, including any folder paths.


Workflow Examples

Example 1: Bundle Reports into a ZIP

Generate multiple files and bundle them into a single downloadable archive.

  1. HTTP Request — Generate or fetch report files.
  2. ZIP Archive > Create ZIP Archive — Bundle all file URLs into monthly-report.zip.
  3. Email — Send the ZIP download link to the recipient.

Example 2: Extract and Process Uploaded Files

Extract files from a ZIP uploaded by a user and process each file individually.

  1. Webhook Trigger — Receive a ZIP file URL.
  2. ZIP Archive > Extract ZIP Archive — Extract all files to Media Library.
  3. Iterator — Loop through {ZIPArchive1.extracted_files}.
  4. (Process each file — rename, move, send, etc.)

Example 3: Archive Management

Inspect an archive, remove outdated files, and add new ones.

  1. ZIP Archive > List ZIP Contents — Inspect archive.zip.
  2. ZIP Archive > Remove Files from ZIP — Remove old-report.pdf.
  3. ZIP Archive > Add Files to ZIP — Add new-report.pdf.
  4. Slack — Notify team that the archive has been updated.

Example 4: Password-Protected Archive Extraction

Extract files from a password-protected ZIP received via webhook.

  1. Webhook Trigger — Receive ZIP URL and password.
  2. ZIP Archive > Extract ZIP Archive — Extract using {Trigger1.password}.
  3. Email — Send extracted file URLs to the admin.

File Storage

  • Created ZIP files and extracted files are saved to the WordPress Media Library.
  • Physical location: wp-content/uploads/{YYYY/MM}/
  • Files are accessible via WordPress media queries and standard URLs.
  • Temporary files created during processing are automatically cleaned up.

Error Handling

Error Message Cause Solution
“File URLs are required” No URLs provided in the input field. Enter at least one valid file URL.
“No valid file URLs provided” All provided URLs were invalid or inaccessible. Check URL format and ensure files are publicly accessible.
“Failed to create ZIP archive” PHP couldn’t create the ZIP file. Check file permissions and available disk space.
“Failed to open ZIP archive” The ZIP file is corrupted or invalid. Verify the ZIP file is valid and not corrupted.
“Failed to extract ZIP archive” Wrong password or corrupted archive. Provide the correct password or verify archive integrity.
“None of the specified files were found” File names don’t match any entries in the archive. Use List ZIP Contents to verify exact file paths.

Note: When some files succeed and others fail, the action still returns status: success with a failed_files array listing the failures. This allows your workflow to continue while still reporting issues.


Tips

  • Use List ZIP Contents first — Before removing files, use List ZIP Contents to see exact file paths.
  • Organize with Base Folders — Use the Base Folder field to create organized directory structures inside your archives.
  • Handle partial failures — Check the failed_files array in the output to handle files that couldn’t be downloaded.
  • Dynamic file lists — Pass file URLs from previous workflow steps using dynamic variables like {HTTPRequest1.file_urls}.
  • Duplicate filenames — If multiple files have the same name, FlowMattic automatically appends -1, -2, etc. to avoid conflicts.

Limitations

  • Cannot create password-protected archives (extraction of password-protected archives is supported).
  • File types extracted from ZIPs must comply with WordPress upload settings.
  • Large archives may require more server memory and processing time.
  • Each file is downloaded individually from its URL during archive creation.

Summary

Feature Details
Connection Required No (built-in core app)
Available Actions 5 (Create, Extract, List Contents, Add Files, Remove Files)
Triggers None
Password Support Extraction only (not creation)
Media Library Automatic upload for created and extracted files
Input Formats Comma-separated URLs, JSON arrays
Base Folder Optional directory structure inside ZIP
Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Access denied
Access denied