[Bug]: Unable to reproduce MudExFileDisplayZip example
HugoVG opened this issue · 2 comments
Contact Details
No response
What happened?
While trying to test out the library for a couple of features one of them I really liked to implement was the MudExFileDisplayZip for a couple zip files, those had their own problems of it not recognizing the file extension.
So I decided to reproduce it on a clean slate which still gave issues in both styling and and functionality
Stacktrace
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN4RBL75CO6F", Request id "0HN4RBL75CO6F:0000002F": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
at MudBlazor.Extensions.Components.MudExImageViewer.DisposeAsync()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.<DisposeAsync>g__Await|26_0(Int32 i, ValueTask vt, List`1 toDispose)
at Microsoft.AspNetCore.Http.Features.RequestServicesFeature.<DisposeAsync>g__Awaited|9_0(RequestServicesFeature servicesFeature, ValueTask vt)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.<FireOnCompleted>g__ProcessEvents|242_0(HttpProtocol protocol, Stack`1 events)
Program.cs
using MudBlazor.Extensions;
using MudBlazor.Services;
using TestMudBlazorExtensions.Components;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddMudServices();
builder.Services.AddMudExtensions();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.UseMudExtensions();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
app.Run();
ZipeFileExplorer.razor
@page "/ZipFileExplorer"
@using MudBlazor.Extensions.Options
@using Nextended.Blazor.Models
<h3>ZipFileExplorer</h3>
@if (Stream != null)
{
<MudGrid Justify="Justify.Center" Style="height: 100%;width: 100%;overflow: auto;">
<MudItem Style="width: 50%;height: 75vh;">
<MudExFileDisplayZip AllowPreview="true"
AllowDownload="true"
ShowContentError="false"
ShowAsTree="true"
AllowToggleTree="true"
@bind-Selected="@Selected"
SelectionMode="ItemSelectionMode.Single"
RootFolderName="sample.zip" ContentStream="Stream"></MudExFileDisplayZip>
</MudItem>
<MudItem Style="width: 50%;height: 75vh;">
<MudExFileDisplay ShowContentError="false"
FileName="@_selected?.FullName"
ContentType="@_selected?.ContentType"
ContentStream="@_selected?.OpenReadStream()"
></MudExFileDisplay>
</MudItem>
</MudGrid>
}
@code {
private IArchivedBrowserFile? _selected => Selected?.FirstOrDefault();
public IList<IArchivedBrowserFile?> Selected { get; set; }
MemoryStream? Stream;
string filepath = "C:\\Users\\------\\Downloads\\TestFolder.zip";
protected override async Task OnInitializedAsync()
{
Stream = new(await File.ReadAllBytesAsync(filepath)); // Test folder different then the work item since that one comes from DB
}
}
_Imports.razor
and App.razor
were setup correctly and i also removed the Bootstrap.css
Expected Behavior
A full working tree, the download button didn't work the file tree looked off and zips in zip didn't work, these probably all have the same cause
Screenshots
Reproduction link
No response
What application type are you referring to?
ServerRendered
Custom Application Type
No response
MudBlazor.Extension Version
1.7.89
MudBlazor Version
6.20.9
What .net Version are you using?
.Net8
What browser are you using?
Chrome, Firefox, Edge
Sample Solution
No response
Pull Request
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Have you called AddMudExtensions or AddMudServicesWithExtensions in your program.cs correctly?
If yes can you upload a small sample solution where this bug occures?
I was changing a lot of stuff and now just came to the issue again where it doesn't understand the zip files from memory stream when it is bytes from a database, but that is not this libraries issue but sharpcompression's problem. I'll close this thread