-
Notifications
You must be signed in to change notification settings - Fork 10.4k
-
It's strange to me that DataTransfer.Files
is a string[]
and there is no reference (that I am aware of) to grab the content of it.
How do I get the file data from an ondrop
event?
void OnDrop(DragEventArgs e) { dragClass = ""; if (Disabled) { return; } var files = e.DataTransfer.Items; if (files.Length == 0) { return; } // What now? }
Is it by-design? Is there even access to an IJSObjectReference
so I can grab it with Javascript?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Hello @datvm,
in Blazor, DataTransfer.Files only gives you file names, the actual file objects stay in the browser. This is by design to avoid automatically streaming large files over the JS/.NET boundary.
If you need the content from an ondrop event, you have to use JS interop to read dataTransfer.files and then send the data back to .NET.
You can’t get the bytes directly from DragEventArgs alone.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for confirming. I had to make it work so like you said I just use Javascript interop for the whole thing.
Beta Was this translation helpful? Give feedback.