ngx-file-drop icon indicating copy to clipboard operation
ngx-file-drop copied to clipboard

[BUG] - after dropped file i get 2 additional DataTransferItems

Open r-hannuschka opened this issue 6 years ago • 2 comments

Just drop 1 file again and again and sometimes i get 1 dropped File and 2 additional DataTransfer Items like this screen.

image

Code looks like the example from your site:

    public drop(files: NgxFileDropEntry[]) {

        files.forEach((file) => {
            if (file.fileEntry.isFile) {
                const dropped = file.fileEntry as FileSystemFileEntry;

                /**
                 * access dropped file
                 */
                dropped.file((droppedFile: File) => {
                    // this prints out file
                    console.log(droppedFile); 
                    const request = this.uploadFactory.createUploadRequest(droppedFile, this.uploadOptions);
                    /** create new upload request and push to storage */
                    this.uploadStorage.add(request);
                });
            }
        });
    }

System: Kubuntu 18.04 Browser Chrome: Version 78.0.3904.87 (Official Build) (64-bit)

I could solve this issue for my self just to check droppedFile is instanceof DataTransferItem and ignore this so i dont get an error in my application but it is more a work arround.

Best regards, Ralf

r-hannuschka avatar Nov 04 '19 19:11 r-hannuschka

This happens to me when I'm dragging and dropping from Outlook. First item is something that's not even a Blob, the second is the actual email. Not sure if expectable or not. I just got it filtered out from the array.

CesarD avatar Dec 04 '20 09:12 CesarD

I have a similar problem. I have like a 50 % chance to get either the file or two DataTransferItems (without the file) when drag and drop from the Dolphin file explorer.

Because droppedFile.fileEntry.isFile is still true for such "empty DataTransferItems", I am filtering for droppedFile.relativePath !== undefined. If then the array of filtered files is empty, I throw an error.

Similar setup but Kubuntu 20.04 and Chrome Version 92.0.4515.159 (Official Build) (64-bit).

I tried figuring out when this is caused, e.g. active/inactive windows, but couldn't find a pattern. Anyway, 50% is quite a high failure rate and whether this is a problem of Dolphin or not I suggest to

  1. improve the property isFile (maybe there is an internal logical error?), and
  2. if possible, give the user some feedback while still dragging by showing a stop symbol at the mouse position if only empty DataTransferItems would be dropped.

antal-huck avatar Sep 06 '21 10:09 antal-huck