Hi,
I'm try to use fileinput component
In my project, fileinput return Unable to read file as base64 string. A task was canceled.
then Attempting to reconnect to the server..
but it work on blazor.radzen.com/fileinput (same image and same code)
Is there any mistake in this?
enchev
January 25, 2021, 12:22pm
2
Such error might happen if the image is too big
thank you
but only about 100kb image(?
And why doesn't this error occur on the sample page?
enchev
January 25, 2021, 12:33pm
4
I’m afraid that in this case I don’t have any other ideas.
I try to find the limit
and I found that the largest file uploaded was 24513 bytes(about 23.9kb)
I don't know what's special about it
Try increasing the Hub options limit:
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddRazorPages();
services.AddServerSideBlazor().AddHubOptions(o =>
{
o.MaximumReceiveMessageSize = 10 * 1024 * 1024;
});
services.AddScoped<ThemeState>();
services.AddScoped<ExampleService>();
services.AddScoped<NorthwindContext>();
services.AddScoped<DialogService>();
services.AddScoped<NotificationService>();
services.AddScoped<TooltipService>();
services.AddScoped<ContextMenuService>();
services.AddScoped<NorthwindService>();
3 Likes
It works!
Thank you very much.!
korchev:
AddHubOptions
I am having this same issue. The same image works fine in the sample page for that component. Using AddHubOptions did not change the outcome. Is there any explanation for this discrepency?
My reply is from 4 years ago and Blazor has changed quite a lot since then Here is the up-to-date code:
1 Like
What error would we catch and handle if the user does select a file that is too large?
When I was running into this error it seemed to be failing silently.
enchev
February 5, 2025, 8:28pm
11
Maybe you can use MaxFileSize to restrict bigger images.
I believe, even with a small MaxFileSize, there is no feedback when the file is selected. (unless there is, and I'm looking in the wrong place).