melihercan / Blazorme

Component libraries for Blazor apps
MIT License
13 stars 0 forks source link

Example for Core Hosted WASM StreamSaver #2

Open michalss opened 2 years ago

michalss commented 2 years ago

HI can you please make an Wasm Hosted example with StreamSaver? Im not sure how to implement server side(api), how exactly send data from server to client, kind of proper way, to make it smoot and working.. To be hones there is not some good working solution for WASM core hosted model here, i was trying to find some good examples how to properly download files from server to client but nothing what is actually working smooth. All solutions are slow, cannot download really big files, so its become useless. But with this your StreamSaver solution it could be different. Just need some good working example. Can you please provide it, or at least how to implement server side routine(how to properly send data from server to client)?

Thx a lot Mike

melihercan commented 2 years ago

Hi Mike, As I mentioned on other posts, I am currently swamped with my current project and currently I have no time to support this kind of requests. But I believe you are in luck, please check my WebRTCme project. There I use StreamSaver in a Blazor WASM Demo app. You can open the solution and make a search on 'IStreamSaver'. This will reveal the related code and you can use them as a reference. I know this is not the easiest way but it is better than nothing.

I don't think that you need to do something specific on the server side. StreamSaver on the client side acts different than the other downloaders in a way that it stores the current incoming chunk directly to a file vs store and accumulate them in memory. This will avoid out of memory issue for very large files.

pablopioli commented 2 years ago

@michalss You can download the info and process it client side in Blazor. It's really no different to another kind of situations.

If it helps here https://github.com/pablopioli/Blazor-QuestPDF/blob/master/Pages/Index.razor I created a sample on how to create a PDF entirely in the client and then download it.