-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[upload] Add support for uploading folders #857
Comments
This is a good idea to offer a slightly better UX for uploading all files in a directory. Can be considered as progressive enhancement imo and ok to implement even if it won't work on all browsers (looks like it's well supported on desktop browsers except not on IE11). Related resources: |
One thing to consider is what should happen if the selected directory contains nested directories with more files (and possibly files of same name in sub directories)? I didn't check if the native APIs allow for getting the whole directory hierarchy or only some flattened list of files from the directory (or does it even get files from sub directories of selected directory?). There could be an additional (optional) related feature that would automatically zip the directory on client side before uploading it. Or other special handling (or customizable handler method) might be needed. We should probably investigate how it behaves in these cases with the native: <input type="file" directory> and try to mimic that behaviour. Possibly providing additional value/features. |
Note, we can use |
Here's the current version of the File and Directory Entries API: https://wicg.github.io/entries-api/ It contains some examples of how to get the directories from the drag and drop (which will require us to change how we handle These APIs could be used to get the contents (individual files) from the folder uploaded using drag & drop. |
Had some fun learning JS and injecting code into Vaadin client: Problems: Does not pass folder structure to server, might be easiest to make with standard element.$server invocation Test with text files, these will print to the screen Tried only in Jetty, might be some problems in production release? Use:
|
If it's not possible to support both files and folders in the native file selector, then we'll just have to accept that, and document that switching to folder mode means you can only upload files thru drag and drop, and that if you need to support both through the native selector, you'll have to provide a toggle for switching between file and folder upload. |
Support for dragging and dropping folders has been added with #8032. For selecting a directory through the native file dialog there is a draft PR here: #8057. As the implementation involves some opinionated choices and browser limitations, we want to outline the planned implementation here in order to possibly get some feedback:
If you have any feedback regarding the proposed implementation please leave a comment. |
Interesting ! Did you consider some sort of upload queueing, so that uploading a directory with hundreds of large files does not swamp the server ? |
Nope, but that seems like a good idea. However I think this is a separate issue and that problem already exists today as you can select an unlimited number of files. So that will probably not make it into a first version of this feature. |
Mentioned issue: #6698 |
It should be possible to select or drop a folder and upload the contents of the folder
The text was updated successfully, but these errors were encountered: