feat: Archive support for Filebrowser by Kosztyk · Pull Request #5960 · filebrowser/filebrowser · GitHub
Skip to content

feat: Archive support for Filebrowser#5960

Open
Kosztyk wants to merge 11 commits into
filebrowser:masterfrom
Kosztyk:archive-support
Open

feat: Archive support for Filebrowser#5960
Kosztyk wants to merge 11 commits into
filebrowser:masterfrom
Kosztyk:archive-support

Conversation

@Kosztyk

@Kosztyk Kosztyk commented May 24, 2026

Copy link
Copy Markdown

Changelog: Archive Browsing and Extraction Support

Summary

This pull request adds archive support to File Browser so users can open supported archive files directly in the web UI, browse their contents like a virtual read-only folder, preview supported files inside the archive, download individual files from inside the archive, and explicitly extract archives or selected archive entries.

The implementation uses the existing github.com/mholt/archives dependency already present in the project, avoiding shelling out to external tools such as unzip, tar, 7z, or rar.

Added

Archive browsing

Users can now open supported archive files from the normal file listing. When an archive is opened, File Browser displays its contents as a virtual folder structure.

Supported first-pass archive formats include:

  • .zip
  • .tar
  • .tar.gz
  • .tgz
  • .tar.bz2
  • .tbz2
  • .tar.xz
  • .txz
  • .tar.zst
  • .tzst
  • .7z
  • .rar

Archive browsing uses URL query state instead of treating archive entries as real filesystem paths. Example:

/files/frontend.zip?archive=/frontend/src/

This keeps archive paths separate from real filesystem paths and avoids ambiguity between a real folder and a file inside an archive.

Virtual archive API

A new archive API layer was added for listing, streaming, and extracting archive contents.

New API behavior:

GET  /api/archive/list/<archive-path>?inner=<archive-inner-path>
GET  /api/archive/raw/<archive-path>?inner=<archive-inner-file>
POST /api/archive/extract/<archive-path>

The list endpoint returns archive contents in a resource-like shape so the existing frontend listing components can render archive folders and files with minimal changes.

The raw endpoint streams a single file from inside an archive so existing preview and download flows can work with archive entries.

The extract endpoint extracts either:

  • the full selected archive when the user selects an archive file outside archive view
  • a selected file or folder from inside an already-opened archive

Preview support inside archives

Supported file types can now be previewed directly from inside archives, including:

  • images
  • audio/video
  • PDF files
  • CSV files
  • text files
  • source/config files

Preview URLs are routed through the new archive raw endpoint when the current view is inside an archive.

Download support inside archives

Users can download individual files from inside an archive without extracting the full archive first.

When the selected item is inside an archive, the download action now targets the archive raw endpoint with the selected inner path.

Extraction actions

The UI now exposes extraction actions in both toolbar and context-menu flows.

Outside an archive:

  • selecting an archive file shows Extract this archive
  • right-clicking an archive file shows Extract this archive

Inside an archive:

  • selecting a file shows Extract this file
  • selecting a folder shows Extract this folder
  • right-clicking an archive entry shows the matching extract action
  • previewing a file inside an archive also exposes Extract this file

Extraction is explicit. Opening or browsing an archive never writes files to disk.

Changed

Frontend routing

Archive state is represented by the archive query parameter.

Example:

/files/frontend.zip?archive=/frontend/

This allows the existing file browser route to remain the main navigation entry point while distinguishing normal filesystem browsing from virtual archive browsing.

Read-only behavior inside archives

Archive contents are treated as read-only.

The following write actions are disabled while browsing inside an archive:

  • upload
  • edit/save
  • rename
  • move
  • copy into archive
  • delete from archive

This prevents File Browser from implying that archive contents can be modified in place.

Toolbar behavior

The toolbar now adapts depending on context:

  • normal selected archive file: shows archive extraction action
  • selected file inside archive: shows file extraction action
  • selected folder inside archive: shows folder extraction action
  • archive entries keep download behavior where valid

Context menu behavior

The right-click menu now includes extraction actions for:

  • archive files selected outside archive view
  • files selected inside archive view
  • folders selected inside archive view

Breadcrumb behavior

Breadcrumbs now understand archive navigation and keep the archive file as the root of the virtual archive path.

Security and safety

The archive implementation includes safeguards to reduce archive-related risks.

Implemented protections:

  • archive browsing is read-only
  • inner archive paths are normalized
  • path traversal attempts are rejected
  • unsafe ../ paths are blocked
  • extraction validates output paths before writing
  • extracted entries must remain inside the selected destination
  • symlinks, device files, named pipes, sockets, and irregular files are skipped during extraction
  • preview size is capped for text-like files
  • archive file access still goes through File Browser's existing user permission model

Archive browsing and file streaming require the user to have permission to access/download the archive file itself.

Files added

http/archive.go

Files modified

files/file.go
files/utils.go
http/http.go

frontend/src/api/files.ts
frontend/src/types/file.d.ts
frontend/src/views/Files.vue
frontend/src/views/files/FileListing.vue
frontend/src/views/files/Preview.vue
frontend/src/views/files/Editor.vue
frontend/src/components/Breadcrumbs.vue
frontend/src/components/files/ListingItem.vue
frontend/src/css/listing-icons.css

Implementation notes

The implementation reuses github.com/mholt/archives, which was already present in the project for archive creation/download functionality.

This keeps archive support inside the Go application and avoids relying on system-level binaries that may not be available in all deployments or containers.

Archive browsing is implemented as a virtual filesystem layer. Archive entries are not extracted during navigation.

Extraction remains a separate user-triggered operation.

Validation performed

The following validation was performed during patch preparation:

  • Go files were formatted with gofmt
  • the generated source archive was checked for ZIP integrity
  • the full patch applies cleanly to the original source tree
  • the incremental UI patch applies cleanly to the previous archive-support version

Validation not performed

A full local build/test run was not completed in the sandbox environment because this File Browser source requires Go >= 1.25.0, while the available sandbox Go version is older and external toolchain download is blocked.

Recommended maintainer-side validation:

go test ./...
npm install
npm run build

or the equivalent frontend package-manager commands used by the project.

User-facing result

After this change, users can:

  1. click an archive file to open it
  2. browse folders inside the archive
  3. preview supported files inside the archive
  4. download individual files from inside the archive
  5. extract a full archive from the normal file list
  6. extract a selected file or folder while browsing inside an archive

@Kosztyk Kosztyk requested a review from a team as a code owner May 24, 2026 10:53
@hacdias hacdias changed the title chore: Archive support for Filebrowser feat: Archive support for Filebrowser Jun 3, 2026
@lapisxalpha

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants