You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<PageTitle>FileAPI - Stream Large Blob</PageTitle>
5
+
6
+
<h2>Streaming a large Blob</h2>
7
+
A common problem that people face when working with files is that they can be very big.
8
+
This is especially a problem if you want to read them in Blazor Server where there is a limit on the size of messages that can be sent over SignalR.
9
+
<br />
10
+
This sample will illustrate stream reading a large Blob to .NET using the inbuilt <code>stream()</code> method available on a <code>Blob</code>.
11
+
<br />
12
+
<br />
13
+
<ol>
14
+
<li>We have created a method in JS called <code>hugeBlob()</code> which creates a huge object in the form of a large empty array, serialized to a JSON string, and then parsed into the <code>Blob</code> constructor.</li>
15
+
<li>We construct a wrapper around the JS object reference <i>(jSBlob)</i> by calling <code>Blob.Create(JSRuntime, jSBlob)</code>.</li>
16
+
<li>We get a <code>ReadableStream</code> from the Blob by calling <coded>await blob.StreamAsync()</coded>.</li>
17
+
<li>We get the default reader of the stream by calling <code>await stream.GetDefaultReaderAsync()</code>.</li>
18
+
<li>We iterate the chunks of the reader and append the chunk to our result. Below you can see chunk sizes read and the length of the result that has been built.</li>
0 commit comments