Skip to content
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

Blazor Support Large File Uploads #33638

Closed
christophwille opened this issue Jun 18, 2021 · 14 comments · Fixed by #33986
Closed

Blazor Support Large File Uploads #33638

christophwille opened this issue Jun 18, 2021 · 14 comments · Fixed by #33986
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future feature-blazor-server feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Milestone

Comments

@christophwille
Copy link

christophwille commented Jun 18, 2021

I have a working Blazor Web Assembly app that uploads files to Azure Storage (server provides SAS token urls, client upload to that destination). This works a-ok for "small" files the size of a couple 100MBs. However, I now have a 6.8GB file that doesn't - I am using bog standard code along the lines of the documentation:

Azure.Response<BlobContentInfo> azresponse = await blobClient.UploadAsync(fileStream, new BlobUploadOptions()
{
  ProgressHandler = new Progress<long>((progress) =>
  {
     vm.ProgressBarPercentage = (int)(100.0 * progress / vm.InputFileSize);
     this.StateHasChanged();
  })
});

For this large file, it returns immediately and creates a zero byte file on Azure Storage. I then tried this:

 var x = new byte[200];
 int res = await fileStream.ReadAsync(x, 0, 100);

Surprisingly, res is 0 so I see why the storage library would create a 0 byte file... but I don't get why Blazor behaves that way. (Note: I didn't test to see at what file size this behavior kicks in). I also didn't see anything that would indicate any sort of error. The stream simply isn't returning data.

@Pilchie Pilchie added the area-blazor Includes: Blazor, Razor Components label Jun 18, 2021
@javiercn javiercn added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Jun 21, 2021
@javiercn
Copy link
Member

@christophwille thanks for contacting us.

Is the stream returning a 0 for the read coming from the InputFile component?

@javiercn javiercn added the feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future label Jun 21, 2021
@christophwille
Copy link
Author

IBrowserFile.Size is telling me the on-disk file size as expected. IBrowserFile.OpenReadStream(8 * 1024 * 1024* 1024) (my current default max limit is 8GB) is giving me a Stream but... then trying to read from it doesn't return anything (no need to upload to Azure, my ReadAsync sample from above is fully sufficient to exhibit the problem - no bytes read)

@javiercn
Copy link
Member

@christophwille thanks for the additional details.

@TanayParikh since you are fiddling with this area, can you give this a try? (Both with the improved implementation and with the old implementation in 5.0)

@javiercn javiercn added the bug This issue describes a behavior which is not expected - a bug. label Jun 21, 2021
@javiercn javiercn added this to the Next sprint planning milestone Jun 21, 2021
@ghost
Copy link

ghost commented Jun 21, 2021

Thanks for contacting us.

We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@TanayParikh
Copy link
Contributor

@TanayParikh since you are fiddling with this area, can you give this a try? (Both with the improved implementation and with the old implementation in 5.0)

Looks like we have a hard limit of Int32.MaxValue = 2147483647 bytes on the file size we can currently upload. This applies for Blazor WASM and Blazor Server. Compiling benchmarks of old vs new implementation and will update accordingly.

@christophwille
Copy link
Author

christophwille commented Jun 22, 2021

Is there a chance to lift this limit in either a point relase for v5 or v6 (I am selfish, WASM-only would be fine)?

Edit: or make it configurable ("I know what I am doing"). But failing silently with 0 bytes is a very strange behavior.

@christophwille
Copy link
Author

Will #33491 lift the limit mentioned in this issue or is this then still another different matter? (I'd be fine moving to Blazor 6 in this specific case, but if it is not gonna get lifted I need to switch to JavaScript)

@TanayParikh
Copy link
Contributor

Will #33491 lift the limit mentioned in this issue or is this then still another different matter?

No unfortunately the limit remains after #33491. I'm investigating if there's a way for us to add in support for files > 2GB, will update here accordingly.

@TanayParikh
Copy link
Contributor

I've put up a proof of concept on what it'd take to implement large file support: #33900

@TanayParikh TanayParikh changed the title Blazor WASM Large File (GB) Upload to Azure Storage Blazor Support Large File Uploads Jun 28, 2021
@christophwille
Copy link
Author

Not having to resort to JS would be absolutely awesome!

@christophwille
Copy link
Author

@TanayParikh What are the chances of this making it into preview7?

@TanayParikh
Copy link
Contributor

@TanayParikh What are the chances of this making it into preview7?

That's still my target; need to merge the following PRs (pending review):

@TanayParikh TanayParikh self-assigned this Jul 14, 2021
@ghost ghost added Done This issue has been fixed and removed Working labels Jul 15, 2021
@christophwille
Copy link
Author

@TanayParikh So this will ship in preview7 roughly mid-August, correct? For my understanding of how this will work: I can keep passing my desire max size to OpenReadStream and have nothing else to change, it will just work?

@TanayParikh
Copy link
Contributor

So this will ship in preview7 roughly mid-August, correct?

Yep!

For my understanding of how this will work: I can keep passing my desire max size to OpenReadStream and have nothing else to change, it will just work?

Exactly, the transition to this new underlying implementation should be entirely seamless on your end. Let me know if you run into any issues 😄

@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future feature-blazor-server feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants