Skip to content

feat: support folder uploads in the asset library - #1336

Merged
stevenle merged 1 commit into
mainfrom
claude/asset-library-folder-uploads-7m898b
Jul 30, 2026
Merged

feat: support folder uploads in the asset library#1336
stevenle merged 1 commit into
mainfrom
claude/asset-library-folder-uploads-7m898b

Conversation

@stevenle

Copy link
Copy Markdown
Member

Adds support for uploading entire folder structures to the asset library, mirroring the directory hierarchy in the asset browser. Users can now upload folders in addition to individual files.

Changes

  • File tree utilities (file-tree.ts): New module for collecting files from folder uploads via two mechanisms:

    • Directory picker (<input type="file" webkitdirectory>) where files carry webkitRelativePath
    • Drag-and-drop with recursive directory walking via the webkitGetAsEntry() file system API
    • Filters out OS metadata files (.DS_Store, Thumbs.db, etc.) and directories (__MACOSX, dotdirs)
    • Caps uploads at 1000 files to bound resource usage
  • Asset folder creation (assets.ts): New createAssetFolderPaths() function that:

    • Creates missing folder hierarchies before file uploads
    • Validates folder path segments using existing validateAssetName()
    • Batches Firestore writes (max 400 ops per batch) to stay within limits
    • Caps folder creation at 200 folders per upload
    • Preserves existing folders and their metadata/sync connections
  • Asset browser UI (AssetBrowser.tsx):

    • Refactored uploadFiles() to accept UploadFileEntry[] instead of raw File[]
    • In "manage" mode, upload button now shows a dropdown menu with "Upload files" and "Upload folder" options
    • Drag-and-drop now supports folders (updated hint text)
    • Handles folder creation errors gracefully with user notification
    • Shows truncation warning if upload exceeds 1000 files
  • Tests (file-tree.test.ts): Comprehensive test coverage for file collection, ignored file/directory filtering, and both upload mechanisms.

Implementation Details

  • UploadFileEntry carries both the file and its relative path within the upload, allowing the asset browser to recreate the folder structure
  • Folder paths are validated and normalized before creation to ensure consistency
  • The drag-and-drop implementation reads entries synchronously (before any await) since DataTransfer is only valid during the event
  • Existing folders are checked before creation to avoid unnecessary writes and preserve user-created metadata

https://claude.ai/code/session_01LRRKBNbBnYV1uhgXo28T8u

The asset library can now take an entire folder, either via the new
"Upload folder" menu item (a `webkitdirectory` picker) or by dropping a
folder onto the listing. The uploaded directory structure is mirrored in
the asset library: missing folders are created (batched) and each file is
uploaded into the folder it came from.

Dropped directories are walked with the file system entries API, paging
`readEntries()` until it comes back empty. Dotfiles and OS metadata
(`.DS_Store`, `__MACOSX`, `Thumbs.db`) are skipped, and uploads are
bounded at 1000 files / 200 folders with a notification when truncated.

Refs #586

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LRRKBNbBnYV1uhgXo28T8u
@stevenle
stevenle merged commit dde79be into main Jul 30, 2026
1 check passed
@stevenle
stevenle deleted the claude/asset-library-folder-uploads-7m898b branch July 30, 2026 17:47
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.

2 participants