cypress-file-upload
cypress-file-upload copied to clipboard
feat: folder upload
Checklist:
- [ ] No linting issues
- [ ] Commits are compliant with commitizen
- [ ] CI tests have passed
- [ ] Documentation updated
Summary of changes
Folder upload implementation
TODO
- [ ] Check if this actually solves use cases
- [ ] Expose required
task
from package - [ ] Update API reference
Linked issues
Closes #141 Closes #69
@abramenal I will try to test it on my use case ... Thank you
Hi there, Looking into this I believe files should also have a webkitRelativePath set.
If you are handling uploaded folders you will need to be checking the items that are dropped to see if they are files or folders with something resembling the following
// dataTransfer is dropped item(s)
toArray(dataTransfer.items)
.forEach((item) => {
const entry = item.webkitGetAsEntry()
// :entry can be null when we drop the url e.g.
if (entry) {
if (entry.isFile) {
// Convert from FileEntry to standard File to upload
entry.file(
(file) => {
file.relativePath = getRelativePath(entry)
files.push(file)
})
}
else if (entry.isDirectory) {
// Handle directory. Recursively select files or do something else
}
}
})
If only folders get the webkitRelativePath treatment then there it seems standard file uploads would fail this check as there would be not webkitFileEntry for the File item.
Please help us to upload folder. We have a critical functionality which uses this functionality.
@abramenal Are you open to using https://uppy.io/examples/dashboard/ for the demo/test cases here? It's the most complete and free upload solution out there and provides one widget for single or multiple files and folders. I think it can help test this new command thoroughly.
Are you planning to merge this soon, we would like to use this functionality?
@StefanBabukov I don't think I'm able to finalize this stuff in the upcoming couple of weeks. If anybody feels empowered to do so – I'm happy to support with review, release, etc.
@abramenal @StefanBabukov This looks like it almost made it over the finish line. Is there a chance of reviving a way to selectFolder? <3
At this point I don't even know if more people have appetite for this. But if anyone here wants to finalize the implementation, I'm happy to help with code review & release process.