feat: support folder uploads in the asset library - #1336
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:<input type="file" webkitdirectory>) where files carrywebkitRelativePathwebkitGetAsEntry()file system API.DS_Store,Thumbs.db, etc.) and directories (__MACOSX, dotdirs)Asset folder creation (
assets.ts): NewcreateAssetFolderPaths()function that:validateAssetName()Asset browser UI (
AssetBrowser.tsx):uploadFiles()to acceptUploadFileEntry[]instead of rawFile[]Tests (
file-tree.test.ts): Comprehensive test coverage for file collection, ignored file/directory filtering, and both upload mechanisms.Implementation Details
UploadFileEntrycarries both the file and its relative path within the upload, allowing the asset browser to recreate the folder structureawait) sinceDataTransferis only valid during the eventhttps://claude.ai/code/session_01LRRKBNbBnYV1uhgXo28T8u