Skip to content
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

feat: drag and drop file upload should not differentiate between files and directories #81

Open
travis opened this issue Jan 11, 2024 · 1 comment

Comments

@travis
Copy link
Contributor

travis commented Jan 11, 2024

We added the ability to upload directories in #79

This introduces kind of a funny UX where you need to be in "file" mode to drag and drop files and "directory" mode to drag and drop directories - it would probably be better to let users drag and drop whatever they want, and only really differentiate between types of uploads in the "click to browse files" flow.

In order to do this we will probably need to move away from the HTML Input-based drag and drop functionality and use the HTML Drag and Drop APIs directly:

https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop

@travis
Copy link
Contributor Author

travis commented Jan 17, 2024

Just want to note that there's an annoying UX quirk that will also be fixed by this - if you try to drop a directory into the "File" upload input the upload UI will hang and never error out. This is partly due to a quirk in the upload-client encoding logic where an error in one of the encoding functions is not caught - after looking at the code I'm not quite sure how to fix:

Screenshot 2024-01-16 at 3 55 21 PM Screenshot 2024-01-16 at 3 55 45 PM

Complicating the fix at the UI level is the fact that in this particular situation the browser passes along a File object representing the directory itself rather than the files in the directory, with no way to tell that the File is actually a directory. If we could tell it was a directory we could just avoid the error-causing situation entirely, but I don't see a clear path to that with the HTMLInput-based drag and drop API.

I could definitely invest more hours into trying to fix this as it is, but it feels like that time would be better spent moving to the newer HTML drag-and-drop API!

travis added a commit to storacha-network/w3up that referenced this issue Jan 17, 2024
right now errors in the `finalize` methods can leave a writer unclosed forever - this should help improve the DX issues described in storacha-network/console#81 (comment) by at least printing an error to the console with information about the problem
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

No branches or pull requests

1 participant