Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing file when dragged from browser #293

Open
Res42 opened this issue Aug 15, 2023 · 1 comment · May be fixed by #294
Open

Missing file when dragged from browser #293

Res42 opened this issue Aug 15, 2023 · 1 comment · May be fixed by #294

Comments

@Res42
Copy link

Res42 commented Aug 15, 2023

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.0
  • angular: 16.1.3
  • chrome: 115.0.5790.171

I debugged the issue and this is what I found.

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.

image

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

image

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.

@Res42 Res42 linked a pull request Aug 16, 2023 that will close this issue
@shamoon
Copy link

shamoon commented Sep 25, 2023

Darn, think we're hitting this issue.

Are you aware of any workaround as the PR seems to be sitting un-merged? It's sort of a killer issue.

@georgipeltekov sorry to bother you, any chance of looking into this / getting the linked PR merged & released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants