-
Notifications
You must be signed in to change notification settings - Fork 37
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
Sep does not support async only streams (such as IBrowserFile) #27
Comments
@Shane88 thank you for your interest in Sep and the detailed issue description. You are right that Sep does not support async usage currently and there are currently no immediate plans to support. However, I do hope to add it at some point, so I will leave this issue open to track it. |
Just to be sure people are aware of this, you can of course copy the stream to a |
Did someone achieve this? var fileStream = new MemoryStream();
var uploadStream = file.OpenReadStream(); // IBrowserFile
await uploadStream.CopyToAsync(fileStream);
using var reader = Sep.Reader().From(fileStream);
Console.WriteLine(reader.HasRows); // False But it works If I use |
@kallebysantos did you reset the memory stream to start after copy e. g. |
Thank you for the quick response. You're right, seems that I forgot to: await uploadStream.CopyToAsync(fileStream);
fileStream.Seek(0, SeekOrigin.Begin); // <- I missed it 🤦I'm around ~3h on this thing |
Happens to all of us 😅 With dotnet 9 improved ref struct support I hope to look at async support based on that. |
When trying to use
Sep.Reader().From(stream)
with a stream returned fromIBrowserFile.OpenReadStream
in the context of a user's browser in a .NET Blazor WASM application, it fails becauseSynchronous reads are not supported.
To my understanding there is no other methods that can be used for Sep to use an asynchronous read from the supplied stream.The stack trace will look like the following inside Blazor WASM:
Note that BrowserFileStream belongs to AspNetCore.Components so I suspect this might also happen other frameworks like MVC but I haven't tested. The msdoc link for the method returning the async only stream is here (IBrowserFile.OpenReadStream(Int64, CancellationToken) Method)
Having had a good look over Seps docs I understand that async stream compatibility might be tricky and out of scope for the intended use of Sep. If that is the conclusion, it would be appreciated to update Sep docs to mention that.
Thinking about what async support might look like with Sep, I thought of the following.
Cheers.
The text was updated successfully, but these errors were encountered: