Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

after downloading a file from wwwroot folder in myblazor app it only get file with 115 kb no matter what is the file size

$
0
0

I created a button on a Radzen page to download a file inside the wwwroot folder. This file is related to a row inside my table on SQL Server database (table name is : Tbl_Tickets).

The file path and file name is saved inside my table in SQL Server database. I created an object of the table named it (tblTicket) to filter inside my wwwroot folder by ticket_Id column.so that i can get the original file from my wwwroot folder.

This is the code of the button in my Blazor page: @page "/AddTicket-Attachment"@inject IJSRuntime JS@inject IWebHostEnvironment environment<RadzenRow><button @onclick="DownloadFileFromURL"> Download Files</button></RadzenRow><script>    window.triggerFileDownload = (fileName, url) => {      const anchorElement = document.createElement('a');      anchorElement.href = '/';      anchorElement.download = fileName ?? '';      anchorElement.click();      anchorElement.remove();    }</script>

And this is the code:

@code {private async Task DownloadFileFromURL(){var fileName = $"{tblTicket.AttchedFileName}";var fileURL = $"{environment.WebRootPath}";await JS.InvokeVoidAsync("triggerFileDownload", fileName, fileURL);}

it is working and download the file.but the problem is ( if the file size is less than 115 kb it can be downloaded and opened with no problem. but if the file size was more than 115 kb it just can be downloaded with 115 kb of size and can't be opened ). so can any one tell me what the problem is in my code


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>