Blazor InputFile - Access IBrowserFile Stream after file list has changed #35178
Labels
area-blazor
Includes: Blazor, Razor Components
feature-blazor-builtin-components
Features related to the built in components we ship or could ship in the future
Is your feature request related to a problem? Please describe.
I am trying to store a stack of IBrowserFiles (images) using one InputFile component (so the user can add one file after the other), where a preview is generated immediately
onchange
, and later when the user clicks submit/save we upload the entire stack to the server.BUT there seem to be no way to access the IBrowserFile stream (
OpenReadStream()
throws) after the file list of the InputFile it originated from has changed.This could be solved by also reading all the files into memory
onchange
, but would be very wasteful as I'm expecting up to 200 files.Describe the solution you'd like
As long as I have a reference to the IBrowserFile in .NET I would like to be able to get it's stream just as I can in JS when keeping a reference to a File.
The changes implemented by @TanayParikh in #33986, looks like it MAY have opened up for an alternative solution to hold a reference to the stream by calling
IBrowserFile.OpenReadStream
(which returns aBrowserFileStream
, which opens a stream viaIJSStreamReference
) before the file list changes. But I have no way of verifying this as that code has yet to be released, and I have a little hard time following all the interop stream code.Additional context
This issue stems from that the original JS objects is stored in a list on the input element, which is cleared each time the file list is changed, and after that the blob I am hoping to stream is gone.
The text was updated successfully, but these errors were encountered: