Tewr / BlazorFileReader

Library for creating read-only file streams from file input elements or drop targets in Blazor.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: additive Drag+Drop possible?

DNF-SaS opened this issue · comments

Hi,

I'd like to fake the popular "dropzone.js" with BlazorFileReader.
Main motivation is, that dropzone.js can collect multiple drag+drops and start the upload afterwards.
Unfortunately, BlazorFileReader's DragDrop-Demo clears the droplist before every dropevent-handling. I'm a simple man, so I removed FileList.Clear() in RefreshFileList()) ;-) - was fine on the first look.
But on the second, I realized that the FileInfo-Contents changed but IFileReference.ReadFileInfoAsync() returned the same stream twice. :-(
What has to be done to mimic "dropzone.js"'s behavior?

Thanks for help!
Sascha

commented

this.elementDataTransfers.set(ev.target, ev.dataTransfer.files);

the file list is being reset upon drop here

I'd have to test but I'm guessing a simple option passed to the register method could make it additive. Currently, it's not really possible, unless you create a new drop target in place of the old one on each drop event.

commented

OK so I had five minutes to look at the demo of dropzone.js, and I agree that BlazorFileReader should be more flexible on this particular point. I'll add the option and a demo when I get the time. Should be relatively simple, however I'll have to workaround the fact that multiple drop events is being raised if I remember correctly, which is currently avoided as we do a complete reset each time.