feat(ux): support uploading folders from the file manager - #5677
Open
stijnwtf wants to merge 1 commit into
Open
Conversation
Adds a folder option alongside file upload, using webkitdirectory input and dataTransfer.items with FileSystemEntry traversal for drag-and-drop, so subdirectories are recreated via the create-folder API before their files are uploaded to the right path.
There was a problem hiding this comment.
Pull request overview
Adds UX support for uploading folders (via picker + drag-and-drop traversal) so that subdirectories are recreated in the server file manager before uploading files into their corresponding paths.
Changes:
- Add a dropdown to choose between uploading files vs. a folder (using
webkitdirectory). - Implement drag-and-drop folder traversal via
dataTransfer.itemsandFileSystemEntryrecursion. - Pre-create nested directories via the create-folder API before uploading files with per-file target directories.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
207
to
+210
| visible.value = false; | ||
| if (!e.dataTransfer?.files.length) return; | ||
|
|
||
| onFileSubmission(e.dataTransfer.files); | ||
| if (e.dataTransfer?.items.length) { | ||
| handleDropItems(e.dataTransfer.items); | ||
| } |
Comment on lines
+186
to
194
| const handleDropItems = async (items: DataTransferItemList) => { | ||
| const entries = Array.from(items) | ||
| .filter((item) => item.kind === 'file') | ||
| .map((item) => item.webkitGetAsEntry()) | ||
| .filter((entry): entry is FileSystemEntry => entry !== null); | ||
|
|
||
| const results = await Promise.all(entries.map((entry) => getAllFilesFromEntry(entry))); | ||
| uploadFilesWithPaths(results.flat()); | ||
| }; |
Comment on lines
+176
to
+180
| } catch (error: unknown) { | ||
| clearFileUploads(); | ||
| clearAndAddHttpError(error); | ||
| }); | ||
| clearAndAddHttpError(error instanceof Error ? error : String(error)); | ||
| return; | ||
| } |
Comment on lines
+151
to
+155
| for (const { file, relativePath } of filesWithPaths) { | ||
| const controller = new AbortController(); | ||
| const lastSlash = relativePath.lastIndexOf('/'); | ||
| const subDir = lastSlash > 0 ? relativePath.substring(0, lastSlash) : ''; | ||
| const targetDirectory = subDir ? `${base}/${subDir}` : directory; |
Comment on lines
+144
to
+148
| try { | ||
| await createDirectory(uuid, dirRoot, dirName); | ||
| } catch { | ||
| // Directory may already exist — creation failures here shouldn't block the upload. | ||
| } |
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 a folder option alongside file upload, using webkitdirectory input and dataTransfer.items with FileSystemEntry traversal for drag-and-drop, so subdirectories are recreated via the create-folder API before their files are uploaded to the right path.