abramenal / cypress-file-upload

File upload testing made easy
https://npm.im/cypress-file-upload
MIT License
496 stars 89 forks source link

feat: folder upload #288

Closed abramenal closed 1 year ago

abramenal commented 3 years ago

Checklist:

Summary of changes

Folder upload implementation

TODO

Linked issues

Closes #141 Closes #69

Donaab commented 3 years ago

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

anark commented 3 years ago

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.

vishnuprabhu-95 commented 3 years ago

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

a-kriya commented 2 years ago

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

StefanBabukov commented 2 years ago

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

abramenal commented 2 years ago

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

kschmarr commented 1 year ago

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

abramenal commented 1 year ago

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.