-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Blazor Server Large File Upload Support #33900
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
Conversation
reader.onerror = function(err): void { | ||
reject(err); | ||
}; | ||
reader.readAsArrayBuffer(file['blob']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't allocate a buffer larger than ~2GB so this'll fail for large files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this back in for now so this PR isn't blocked on WASM streaming interop. Will remove it in that PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this back in for now so this PR isn't blocked on WASM streaming interop. Will remove it in that PR.
Are you saying that, as of this PR, we still won't support >2GB files but it will nearly support it and then when you do the WASM piece it will support it on Server too?
If so that's totally fine - just want to check I understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of this PR we'll support >2GB in server and up to the current ~2GB limit in WASM. With the new WASM PR, I have >2GB working in WASM as well (using this Blob.slice
approach).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TanayParikh where can I find this "the new WASM PR" and information weather Blazor WASAM 6.0 supports >2GB upload or not?
I can't find any documentation or examples on uploading >2GB file in WASM to an API (preferably with progressive information for UI display)? The docs on Blazor file upload doesn´t event mention the <2GB limit
Its totally unclear if this works now in .net 6.0 , just like I think you are pointing out here.
The internet is littered with questions like this and this and no answers.
Hope you can point me in the right direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where can I find this "the new WASM PR"
weather Blazor WASAM 6.0 supports >2GB upload or not?
It does.
I can't find any documentation or examples on uploading >2GB file in WASM to an API (preferably with progressive information for UI display)?
The process is the same as you would take to upload files < 2GB. We recently added docs for showing progress for uploads in Blazor server (here), you should be able to use that as guidance for implementing something similar in Blazor WASM.
The docs on Blazor file upload doesn´t event mention the <2GB limit
The 2GB limit in .NET 5 and before was un-intended and un-documented behavior. This has been resolved in .NET 6. I've created an issue to add a notice for this limitation in .NET 5 to the docs. dotnet/AspNetCore.Docs#24381
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for the update. This helped me allot deciding on my next steps
src/Components/Web.JS/src/Platform/Circuits/CircuitStreamingInterop.ts
Outdated
Show resolved
Hide resolved
src/Components/Web.JS/src/Platform/Circuits/CircuitStreamingInterop.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
Only have a few comments left
src/JSInterop/Microsoft.JSInterop.JS/src/src/Microsoft.JSInterop.ts
Outdated
Show resolved
Hide resolved
@javiercn @SteveSandersonMS could I please get a review, hoping to get it in for Preview 7. |
src/Components/Web.JS/src/Platform/Circuits/CircuitStreamingInterop.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! One or two minor comments added, but should be basically ready to go :)
I think you spotted one of the comments - the other is at #33900 (comment) in case it gets lost. |
Currently we have a hard limit of
Int32.MaxValue = 2147483647
bytes on the file size we can upload. This applies for Blazor WASM and Blazor Server.The goal of this PR is to remove this limit, using the
Blob.slice
API. Originally I had planned on usingBlob.stream
however that had browser compatibility issues and added complexity when piping between the file stream and the JS<>.NET interop stream.This specific PR is for Blazor Server. I'm working on bringing streaming to BlazorWasm and will integrate this new approach in that PR for BlazorWasm specifically.
Testing: We already have E2E testing for the input file functionality.
It leverages theBlob.stream
API, using the stream we cangetReader
which returns aReadableStreamDefaultReader
. TheReadableStreamDefaultReader
itself is still marked 'experimental' but has been supported in Edge/Chrome/Firefox 79/78/65, however is missing in IE/Safari (will need to test what happens with this in Safari).Part of: #33638