Coder Social home page Coder Social logo

stefh / blazor.downloadfilefast Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 4.0 8.66 MB

Fast download from files to the browser from Blazor without any javascript library reference or dependency.

License: MIT License

C# 72.98% JavaScript 4.37% HTML 9.07% CSS 13.23% Batchfile 0.35%

blazor.downloadfilefast's Introduction

Hi ๐Ÿ‘‹, I'm Stef Heyenrath

stefh

  • ๐Ÿ”ญ Iโ€™m currently working on WireMock.Net
  • ๐ŸŒฑ Iโ€™m currently learning more Azure and Blazor

Environments

windows azure docker linux

Languages

csharp dotnet nodejs javascript typescript

Frontends

blazor angularjs vuejs bootstrap html5 chartjs

stefh

stefh

mr62rashy

blazor.downloadfilefast's People

Contributors

buzzdee4000 avatar stefh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

blazor.downloadfilefast's Issues

When this nuget is added to my Blazor WASM project, the app does not load

As the title says. I've got a working Blazor WASM project using .Net 6 and VS 2022.
I download this nuget and then start the app and get the following exception on the console:

blazor.webassembly.js:1 System.AggregateException: One or more errors occurred. (Invalid JS call result type '3'.
Error: Invalid JS call result type '3'.
    at S (https://localhost:7171/_framework/blazor.webassembly.js:1:5038)
    at Object.invokeJSFromDotNet (https://localhost:7171/_framework/blazor.webassembly.js:1:3170)
    at Object.At [as invokeJSFromDotNet] (https://localhost:7171/_framework/blazor.webassembly.js:1:58414)
    at _mono_wasm_invoke_js_blazor (https://localhost:7171/_framework/dotnet.6.0.0.a1fp8dqnl9.js:1:193780)
    at wasm://wasm/00945abe:wasm-function[2588]:0x8065b
    at wasm://wasm/00945abe:wasm-function[2307]:0x689a7
    at wasm://wasm/00945abe:wasm-function[7015]:0x17bac4
    at wasm://wasm/00945abe:wasm-function[6830]:0x172bc5
    at wasm://wasm/00945abe:wasm-function[3524]:0xb47cc
    at wasm://wasm/00945abe:wasm-function[675]:0x16602)
 ---> Microsoft.JSInterop.JSException: Invalid JS call result type '3'.
Error: Invalid JS call result type '3'.
    at S (https://localhost:7171/_framework/blazor.webassembly.js:1:5038)
    at Object.invokeJSFromDotNet (https://localhost:7171/_framework/blazor.webassembly.js:1:3170)
    at Object.At [as invokeJSFromDotNet] (https://localhost:7171/_framework/blazor.webassembly.js:1:58414)
    at _mono_wasm_invoke_js_blazor (https://localhost:7171/_framework/dotnet.6.0.0.a1fp8dqnl9.js:1:193780)
    at wasm://wasm/00945abe:wasm-function[2588]:0x8065b
    at wasm://wasm/00945abe:wasm-function[2307]:0x689a7
    at wasm://wasm/00945abe:wasm-function[7015]:0x17bac4
    at wasm://wasm/00945abe:wasm-function[6830]:0x172bc5
    at wasm://wasm/00945abe:wasm-function[3524]:0xb47cc
    at wasm://wasm/00945abe:wasm-function[675]:0x16602
   at Microsoft.JSInterop.WebAssembly.WebAssemblyJSRuntime.InvokeJS(String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)
   at Microsoft.JSInterop.JSInProcessRuntime.Invoke[IJSVoidResult](String identifier, Int64 targetInstanceId, Object[] args)
   at Microsoft.JSInterop.JSInProcessRuntime.Invoke[IJSVoidResult](String identifier, Object[] args)
   at Microsoft.JSInterop.JSInProcessRuntimeExtensions.InvokeVoid(IJSInProcessRuntime jsRuntime, String identifier, Object[] args)
   at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.AttachRootComponentToBrowser(Int32 componentId, String domElementSelector)
   at Microsoft.AspNetCore.Components.RenderTree.WebRenderer.AddRootComponent(Type componentType, String domElementSelector)
   at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.AddComponentAsync(Type componentType, ParameterView parameters, String domElementSelector)
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.<>c.<<RunAsyncCore>b__15_1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.RunAsyncCore(CancellationToken cancellationToken, WebAssemblyCultureProvider cultureProvider)
   at Program.Main(String[] args) in Program.cs:line 41
   --- End of inner exception stack trace ---

Program.cs:line 41 is builder.Build().RunAsync()

I've tried it with an empty project as well, there it did not cause this issue. Unfortunately, I cannot share the project where the problem happened, but I'm happy to answer any questions.

Example of use with Wasm Core Hosted

Hi can you please add example how to use it with core hosted type of wasm ? It is all depending how you gonna get bytes from server side. Dont see any point to generate some random bytes on client side, it is pretty useless right ?

Regards

Download Excel file

Hi, can you please show me how to download excel or csv file from list of objects?
thanks a lot.

Download from a URL

Just thought to get your feedback on this.

I am using the following code to create a byte[] from a (video) URL and then your component and it works just splendidly but do you see an issue with it or recommend that I use something else?

private async Task DownloadAsync(string path)
{
    using var client = new HttpClient();
    using var response = await client.GetAsync(path.Url);
    byte[] imageBytes = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
    await BlazorDownloadFileService.DownloadFileAsync("Video.mp4", imageBytes);
}

Would you do something else or is this just fine in WASM Blazor-land?

p.s
The video files can get pretty large.

e.s
Would be great to have a BlazorDownloadFileService.DownloadFileFromUrlAsync() method

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.