Skip to content

Commit 6c7e8bf

Browse files
committed
adding the proof ttha DIMD.DI-6.2.0-preview-01 wors with Blazor file uploading .NET 7 #547
1 parent be36fb0 commit 6c7e8bf

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

samples/BlazorServerSide/BlazorServerSide.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
1212

13-
<PackageReference Include="DryIoc.Microsoft.DependencyInjection" Version="6.1.1" />
13+
<PackageReference Include="DryIoc.Microsoft.DependencyInjection" Version="6.2.0-preview-01" />
1414
<!-- <ProjectReference Include="..\..\src\DryIoc.Microsoft.DependencyInjection\DryIoc.Microsoft.DependencyInjection.csproj" /> -->
1515
</ItemGroup>
1616

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@page "/upload"
2+
3+
<InputFile OnChange="UploadFile" />
4+
5+
@_newDocumentUploadProgress %
6+
@code {
7+
private double _newDocumentUploadProgress;
8+
private async Task UploadFile(InputFileChangeEventArgs args)
9+
{
10+
var file = args.File;
11+
await using var uploadStream = file.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024);
12+
var bytesRead = 0;
13+
var totalRead = 0;
14+
var buffer = new byte[10];
15+
await using var memStream = new MemoryStream();
16+
17+
while ((bytesRead = await uploadStream.ReadAsync(buffer)) != 0)
18+
{
19+
totalRead += bytesRead;
20+
21+
await memStream.WriteAsync(buffer, 0, bytesRead);
22+
23+
_newDocumentUploadProgress = (totalRead / uploadStream.Length) * 100;
24+
StateHasChanged();
25+
}
26+
27+
memStream.Position = 0;
28+
}
29+
}

samples/BlazorServerSide/Shared/NavMenu.razor

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
2525
</NavLink>
2626
</div>
27+
<div class="nav-item px-3">
28+
<NavLink class="nav-link" href="upload">
29+
<span class="oi oi-cloud-upload" aria-hidden="true"></span> Upload file
30+
</NavLink>
31+
</div>
2732
</nav>
2833
</div>
2934

test/DryIoc.TestRunner/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public static void Main()
1313
// todo: @wip
1414
// new GHIssue565_Is_ignoring_ReuseScoped_setting_expected_behaviour_when_also_set_to_openResolutionScope().Run();
1515

16+
// new IssuesTests.Samples.DefaultReuseTest().Run();
1617
// new PropertyResolutionTests().Run();
1718
// new GHIssue391_Deadlock_during_Resolve().Run();
1819
// new GHIssue559_Possible_inconsistent_behaviour().Run();

0 commit comments

Comments
 (0)