cypress-file-upload icon indicating copy to clipboard operation
cypress-file-upload copied to clipboard

feat: folder upload

Open abramenal opened this issue 3 years ago • 6 comments

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 avatar Apr 06 '21 20:04 abramenal

@abramenal I will try to test it on my use case ... Thank you

Donaab avatar Apr 07 '21 19:04 Donaab

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.

anark avatar May 01 '21 17:05 anark

Please help us to upload folder. We have a critical functionality which uses this functionality.

vishnuprabhu-95 avatar May 24 '21 19:05 vishnuprabhu-95

@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.

a-kriya avatar Aug 02 '21 21:08 a-kriya

Are you planning to merge this soon, we would like to use this functionality?

StefanBabukov avatar Aug 18 '21 10:08 StefanBabukov

@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 avatar Aug 18 '21 14:08 abramenal

@abramenal @StefanBabukov This looks like it almost made it over the finish line. Is there a chance of reviving a way to selectFolder? <3

kschmarr avatar Oct 28 '22 16:10 kschmarr

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.

abramenal avatar Nov 25 '22 11:11 abramenal