Skip to content
LibreCodeCoopPublic

About

Bring extraction to your nextcloud web interface

Resources

Stars

65 stars

Watchers

6 watching

Forks

Latest commit

Β 

History

732 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Extract

Latest Release License: AGPL-3.0 Nextcloud Version PHP Version

Extract archives from the Nextcloud web interface. Pick an archive in the Files app, choose Extract… and enter a new folder name or a relative path inside the archive directory.

✨ Features

  • πŸ—œοΈ Choose an extraction destination from the Files action, no shell access needed
  • πŸ—‚οΈ Multiple formats: Zip, Rar, Tar, Tar.gz, Tar.bz2, Gzip, 7z and Deb
  • πŸ“ Works with external storage, including group folders
  • πŸ”’ Imports files through Nextcloud's files API, checking destination permissions and rejecting symbolic links
  • 🧹 Cleans up a temporary directory left behind by an interrupted run
  • πŸ”Œ Capabilities API so clients can discover the supported archive types
  • 🌍 Translated through the Nextcloud translation pipeline
  • πŸ§ͺ Unit tested with Playwright integration coverage for Nextcloud 33–35

πŸ“‹ Requirements

Component Version
Nextcloud 33-35
PHP 8.3–8.5
Node.js 24+ (development only)
npm 10.5+ (development only)

Archive tooling

Tool Purpose Install
PHP zip extension Zip archives bundled with most PHP builds
PHP rar, unrar or full 7z Rar archives pecl install rar or apt-get install unrar or apt-get install 7zip
p7zip / p7zip-full Tar, Gzip, Bzip2, 7z, Deb apt-get install p7zip p7zip-full

Extraction needs enough free space in the server's temporary directory for the uncompressed archive. Symbolic links in archives are not supported.

External decoders require PHP proc_open to be enabled; if it is disabled, extraction fails closed rather than falling back to unsupervised exec(). ZIP extraction enforces the destination's available Nextcloud quota, staging disk free space, and two configurable safety limits (defaults: 2 GiB total uncompressed bytes and 10,000 entries). The limits apply before extraction using ZIP metadata and during streaming using the actual bytes written. Administrators may adjust them for trusted large archives, for example:

occ config:app:set extract max_extracted_bytes --value=4294967296
occ config:app:set extract max_archive_entries --value=20000

The same configured limits and destination-space estimates are now checked against the declared contents of archives handled by 7za (7z, tar, Gzip, Bzip2 and Deb) before launching their extraction. Unlike the ZIP streaming path, an external decoder may expand beyond dishonest archive metadata before the app can stop it. Command-line decoders now run under a best-effort supervisor that periodically measures the staging directory, interrupts processes that exceed the configured size or entry budget, and enforces a default 300-second timeout. Administrators can change it with occ config:app:set extract max_extraction_seconds --value=600. Checks are periodic and can be exceeded briefly; this is not a strict filesystem quota. High-risk deployments should isolate temporary storage with an operating-system-enforced limit. When available, the supervisor runs command-line decoders in their own POSIX session and terminates remaining child processes on completion or failure. The PHP rar extension follows a separate bounded streaming path with CRC checks rather than spawning a decoder, but it still cannot provide an operating-system-enforced CPU or disk quota.

The zip PHP extension is required for ZIP files. RAR uses the PHP rar extension, unrar, or full 7z. TAR, XZ, 7z, gzip, bzip2, and DEB use 7za. Zstandard (.zst and .tar.zst) uses the optional zstd executable, or full 7z 24.01 or newer. Zstandard archives do not reliably expose an expanded size in archive listings, so the staging supervisor is the protection for these formats; its limits are best-effort, not strict disk quotas.

Ubuntu / Debian

sudo apt-get install p7zip p7zip-full unrar zstd

Fedora / RHEL / CentOS

sudo dnf install p7zip p7zip-plugins unrar zstd

macOS

brew install p7zip zstd

πŸ“¦ Installation

Note: Release archives must be built, verified and signed by the publishing workflow. Use verified release assets rather than unreviewed source snapshots.

From a release archive (recommended)

  1. Download the latest extract.tar.gz (or extract.zip) from the releases page.
  2. Extract it into your Nextcloud apps directory, using the command that matches the archive you downloaded:
    # If you downloaded extract.tar.gz:
    tar -xzf extract.tar.gz -C /path/to/nextcloud/apps
    
    # If you downloaded extract.zip:
    unzip extract.zip -d /path/to/nextcloud/apps
    
    chown -R www-data:www-data /path/to/nextcloud/apps/extract
    The archive already contains the built frontend assets, so no Node.js step is needed.
  3. Enable the app:
    occ app:enable extract

From source

  1. Clone the repository into your Nextcloud apps directory:

    cd /path/to/nextcloud/apps
    git clone https://github.com/LibreCodeCoop/extract.git extract
  2. Set the permissions:

    chown -R www-data:www-data extract
  3. Install the PHP and frontend dependencies and build the assets:

    cd extract
    composer install
    npm ci
    npm run build
  4. Enable the app:

    occ app:enable extract

    Or go to Settings β†’ Apps, find "Extract" in the disabled apps section and click Enable.

πŸš€ Usage

  1. Open the Files app and navigate to an archive.
  2. Right-click the archive and choose Extract….
  3. Choose a new folder name or nested relative path and confirm. The default is derived from the archive name; cancelling does not extract anything.

The action is offered for readable archives when you can create files in their parent folder. Extraction never modifies the archive itself.

If an archive contains a filename the Nextcloud storage cannot represent (including some legacy character encodings), extraction fails explicitly rather than discarding those entries and reporting a misleading success. Valid UTF-8 names are preserved. A newly created target folder is removed if the import fails partway through. Legacy clients merging into an existing folder may still leave partial changes, since deleting that folder could destroy pre-existing user data.

Supported formats

Format Extensions Extraction backend
Zip .zip PHP zip extension
Rar .rar PHP rar extension, unrar, or full 7z fallback
Tar .tar 7za
Tar + Gzip .tar.gz, .tgz 7za
Tar + Bzip2 .tar.bz2, .tbz2 7za
Tar + XZ .tar.xz, .txz 7za (two-pass)
Zstandard .zst, .zstd zstd or full 7z 24.01+
Tar + Zstandard .tar.zst, .tar.zstd, .tzst zstd or full 7z 24.01+, then 7za
Gzip .gz 7za
7z .7z 7za
Deb .deb 7za

On systems without the PHP rar extension or unrar, the full 7z executable can extract supported RAR archives as an additional fallback. The smaller 7za executable does not necessarily support RAR or Zstandard; on Debian 13, install the 7zip package to obtain the full decoder. For Zstandard, installing the zstd command is sufficient and works even when older full 7z versions cannot decode .zst.

Note: Archives protected by a password are not supported. Extraction works on a normal Nextcloud data directory, on object storage and with server-side encryption enabled. On non-local storage the archive is unpacked into a temporary directory and the result is imported through the Nextcloud filesystem, so it appears in the Files app like any other folder.

External storage

Archives on external and local storage are unpacked into a request-owned temporary directory and imported through the Nextcloud files API. This avoids cross-device renames and updates the file cache for the destination. Temporary staging content is removed after the request, including on failure.

πŸ› οΈ Development

Prerequisites

  • Node.js 24+
  • npm 10.5+
  • PHP 8.1+ with the zip extension
  • Nextcloud 33-35 development environment

Setup

git clone https://github.com/LibreCodeCoop/extract.git
cd extract
composer install
npm ci

Build commands

npm run dev               # development build
npm run build             # production build
npm run watch             # rebuild on change
npm run lint              # ESLint
npm run lint:fix          # ESLint with autofix
npm run stylelint         # Stylelint
npm run typescript:check  # tsc --noEmit
npm run typescript:generate  # regenerate OpenAPI types from openapi.json

The Makefile wraps the common flows:

make dev-setup          # clean, install and build the production bundle
make production-setup   # same as dev-setup
make appstore           # build the installable extract.tar.gz and extract.zip
make test               # run the PHPUnit suite and the frontend linter
make lint               # run the PHP and frontend linters
make dist               # build the source package and the app-store archives

make appstore stages only the runtime files, then writes build/artifacts/extract.tar.gz and, when zip is installed, build/artifacts/extract.zip. Without zip it skips the zip with a warning; install zip when both archive formats are required.

It packages whatever is already in js/ and css/, and it does not build the frontend itself, so run make build first on a fresh checkout. make dist is not a substitute: it only runs the source and app-store targets.

πŸ§ͺ Testing

Run the PHPUnit suite:

composer run test:unit     # phpunit -c tests/phpunit.xml

Static analysis and linting:

composer run lint          # php -l over every PHP file
composer run cs:check      # php-cs-fixer --dry-run
composer run psalm         # Psalm
npm run lint               # ESLint
npm run typescript:check   # TypeScript

The PHPUnit suite covers the extraction service, the capabilities endpoint and the mapping between Nextcloud's archive MIME types and the extraction strategy.

🚒 Releases

Official releases are tracked in the LibreCodeCoop/extract repository. The source build can be packaged with make build followed by make appstore. A release must only be published after review and validation; this contribution does not introduce automatic release publishing.

πŸ› Troubleshooting

The "Extract here" action is missing

  1. Confirm the Extract app is enabled in Settings β†’ Apps.
  2. Check that the file is one of the supported formats.
  3. Make sure you have permission to change the file; the action needs update rights.
  4. Review the Nextcloud log at data/nextcloud.log.

"Oops something went wrong."

The archive tool could not unpack the file. Common causes:

  • Tool missing: for RAR install the PHP rar extension, unrar, or full 7z; for TAR, XZ, 7z, gzip, bzip2 and DEB install p7zip-full and check that 7za is on the web server user's PATH. For Zstandard install zstd or full 7z version 24.01 or newer.
  • Damaged or unreadable archive: the file is truncated, corrupt, or not actually an archive of that format.
  • Permissions: the web server user cannot read the archive or write into the target folder.
  • Insufficient space on the volume holding the archive.

For a failed external decoder, the Nextcloud log records the rejection reason (for example a timeout, output limit or nonzero exit). To avoid unbounded memory consumption, raw decoder output is not retained in extraction logs.

"Unsupported archive type"

The file's MIME type is not one the app can extract. See supported formats for the list.

Extraction on object storage or with server-side encryption

This works. Nextcloud cannot hand out a path inside the data directory there, so the archive is unpacked into a temporary directory and the result is imported through the Nextcloud filesystem. The extracted folder then appears in the Files app like any other folder.

  • Object storage (S3, Swift, …). getLocalFile() returns a temporary copy rather than a file in the data directory.
  • Server-side encryption enabled. The encryption storage wrapper does the same, because it has to decrypt to a temporary file first.

Both local and non-local archives are staged separately and published through Nextcloud's files API. The backend never unpacks into an untracked path next to the original file.

If extraction used to report "Extraction is only supported on local storage" on these setups, update to a version that includes the import step.

A password-protected archive

Password-protected archives are not supported, including ZIP, 7z, and RAR. An encrypted archive must not be reported as successfully extracted.

Large archives

Extraction happens on the server, so give the PHP process enough memory and time. Very large archives may need a higher memory_limit and max_execution_time.

🀝 Contributing

Contributions are welcome.

  1. Fork the repository.
  2. Create a branch for your change.
  3. Make your change and add or update tests.
  4. Run the checks: composer run test:unit && composer run lint && npm run lint.
  5. Commit with a conventional commit message, for example fix: handle empty archives.
  6. Push the branch and open a Pull Request.

The commit type drives the release:

Commit Release
breaking change (feat!, BREAKING CHANGE) major
feat minor
perf minor
fix(deps) minor
fix (any other scope) patch
chore, docs, test, ci, refactor, style, build, revert none

So a dependency fix bumps the minor version, while an ordinary bug fix bumps the patch version.

πŸ“„ License

This project is licensed under the GNU Affero General Public License v3.0 or later - see the COPYING file for details.

πŸ”— Links

Release and test automation

See release procedures for Nextcloud 33–35 release branches, the PHP matrix, Playwright, reproducible package validation and LibreCode Release Tool automation.

About

Bring extraction to your nextcloud web interface

Resources

Stars

65 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages