I have this method in my blazor web app which I use to get a files' url from my api.The files are already uploaded in AzureBlobStorage and when I try to download them directly from the URL that my API provides me, I can open them and they're all fine.
However, when I try it with my methods, the download is successful but the I cannot open them since they seem to be corrupted.
My blazor method:
public async Task DownloadStream(FileProperties file){ DisableButton = true; try { var blobUrl = await _httpClient.GetBlobUrl(file.Id.ToString()); await _jsRuntime.InvokeVoidAsync("fileDownload", blobUrl, file.Name); } catch (Exception ex) { Console.WriteLine("ERROR: JS method missing... " + ex.Message); } DisableButton = false;}My Javascript method that I invoke in my method:
function fileDownload(base64String, fileName) { console.log("url=", base64String); const a = document.createElement("a"); a.href = base64String; a.download = fileName; a.target = "_blank"; // Open in new tab if needed document.body.appendChild(a); a.click(); document.body.removeChild(a);}What am I missing here?