Skip to content

[Draft] feat: browser-side zip grouping for uploads (AI-generated, unreviewed) - #415

Draft
i0rt wants to merge 2 commits into
Forceu:masterfrom
i0rt:master
Draft

[Draft] feat: browser-side zip grouping for uploads (AI-generated, unreviewed)#415
i0rt wants to merge 2 commits into
Forceu:masterfrom
i0rt:master

Conversation

@i0rt

@i0rt i0rt commented Aug 7, 2026

Copy link
Copy Markdown

Description

Note on intent: This PR isn't submitted as a polished, merge-ready feature. It's a fast, admittedly dirty implementation meant to provide a working solution for users who genuinely need client-side zip grouping right now (as I did). Treat it as a starting point / reference rather than a finished contribution — it will likely need cleanup, review, and possibly rework before it's suitable to merge as-is. Note also that I have not reviewed the code myself.

Compress multiple files into a single zip archive in the browser (via JSZip) before upload. Preserves folder structure and shows compression progress and resulting size. Enabled by default; disabled for end-to-end-encrypted uploads.

Naming: single-folder uploads use the folder name plus a timestamp; otherwise an editable template with strftime-style date tokens is used, falling back to GOKAPI_DEFAULT_ZIP_NAME when the field is left empty. A single loose file is never zipped and uploads as-is.

Add GOKAPI_DEFAULT_ZIP_NAME env var (default gokapi-upload-%Y%m%d-%H%M%S).

Implementation notes: adds a new admin_ui_zip.js that intercepts files as they are added to the dropzone, buffers a batch, compresses it with JSZip, and hands the resulting archive back as a single regular upload. Vendors jszip.min.js (v3.10.1, MIT/GPLv3). Adds a "Zip Archive" option card with an enable toggle and an editable name-template field to the admin upload UI. On the Go side, adds the DefaultZipName environment setting and passes it to the admin view so the browser can use it as the default naming template. Regenerates the minified admin.min.*.js and gokapi.min.*.css bundles.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor / Chore

Technical Details

  • Database changes: No
  • Storage backend affected: No
  • Usage of AI: Yes — this change was generated in full with Claude AI assistance, including the JavaScript feature (admin_ui_zip.js), the template/CSS changes, and the Go environment-variable plumbing (GOKAPI_DEFAULT_ZIP_NAME). The code has not been human-reviewed.

How Has This Been Tested?

  • Manual Testing: Uploaded single files (verified they are not zipped and upload as-is), multiple files (verified they are grouped into one archive), and a single folder (verified the archive is named after the folder plus a timestamp). Verified archive contents and preserved folder structure, the name-template field and its placeholder, the GOKAPI_DEFAULT_ZIP_NAME default, compression progress and resulting-size display, and that the option is disabled for end-to-end-encrypted uploads. Also verified Upload, Delete, and Download still work.
  • Unit Tests: go test ./...
  • Environment: Docker inside WSL2

Checklist

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation. (Only the auto-generated environment-variable reference in docs/advanced.rst was updated — via go generate, to add the GOKAPI_DEFAULT_ZIP_NAME entry.)
  • My changes generate no new warnings.

i0rt added 2 commits August 7, 2026 14:46
Compress multiple files into a single zip archive in the browser (via
JSZip) before upload. Preserves folder structure and shows compression
progress and resulting size. Enabled by default; disabled for
end-to-end-encrypted uploads.

Naming: single-folder uploads use the folder name plus a timestamp;
otherwise an editable template with strftime-style date tokens is used,
falling back to GOKAPI_DEFAULT_ZIP_NAME when the field is left empty.
A single loose file is never zipped and uploads as-is.

Add GOKAPI_DEFAULT_ZIP_NAME env var (default gokapi-upload-%Y%m%d-%H%M%S).
Regenerate minified admin JS and main CSS bundles with the pinned
minifier (tdewolff/minify v2.24.11) and update the auto-generated
environment-variable docs to include GOKAPI_DEFAULT_ZIP_NAME.
@i0rt

i0rt commented Aug 7, 2026

Copy link
Copy Markdown
Author

This is related to #106

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant