-
Notifications
You must be signed in to change notification settings - Fork 102
Description
The file is missing when I drag a file from the browser, for example an image is dragged and dropped from a google image search result page to the dropzone.
Maybe related issue:
Versions:
ngx-file-drop: 16.0.0angular: 16.1.3chrome: 115.0.5790.171
I debugged the issue and this is what I found.
ngx-file-drop/projects/ngx-file-drop/src/lib/ngx-file-drop.component.ts
Lines 203 to 230 in 99180cf
| private checkFile(item: DataTransferItem | File): void { | |
| if (!item) { | |
| return; | |
| } | |
| // if ("getAsFile" in item) { | |
| // const file = item.getAsFile(); | |
| // if (file) { | |
| // this.addToQueue( | |
| // this.getFakeDropEntry(file) | |
| // ); | |
| // return; | |
| // } | |
| // } | |
| if ("webkitGetAsEntry" in item) { | |
| let entry = item.webkitGetAsEntry(); | |
| if (entry) { | |
| if (entry.isFile) { | |
| const toUpload: NgxFileDropEntry = new NgxFileDropEntry(entry.name, entry); | |
| this.addToQueue(toUpload); | |
| } else if (entry.isDirectory) { | |
| this.traverseFileTree(entry, entry.name); | |
| } | |
| return; | |
| } | |
| } | |
| this.addToQueue(this.getFakeDropEntry((item as File))); | |
| } |
checkFile is called, but item.webkitGetAsEntry() returns null, so it uses the fallback to pass the DataTransferItem raw.
The (onFileDrop) output emits this DataTransferItem but it is empty (if it was not empty then I could have made a workaround for this bug).
There was a pull request to use getAsFile which seems to work for my use case #263, but it was reverted adcb504 (#268).
I'd be happy to create a pull request to fix this issue: use getAsFile but code it so it does not break folder uploads, maybe running it only when item.webkitGetAsEntry() == null would sidestep the problem.

