I implemented TelerikUpload in my project. Upload is working fine.
My following code is downloading the file to download folder then I have to click it to open the folder. But I want the file to open in a new tab or in a popup window without the download.
I tried all options, Any option I try it is always downloading to download folder.
Is it because my Blazor application is a single page app?
//JRazor file
<a href="" @onclick="() => AttachmentOpen(item)" @onclick:preventDefault target="_blank">fileName</a>
function openFile(filename, content, mimeType) {
var blob = new Blob([content], { type: mimeType });
var url = window.URL.createObjectURL(blob);
var anchorElement = document.createElement('a');
document.body.appendChild(anchorElement);
anchorElement.setAttribute("type", "hidden");
anchorElement.href = url;
anchorElement.target = "_blank";
anchorElement.click();
anchorElement.remove();
window.URL.revokeObjectURL(url);
}
//Razor.cs file
private async Task AttachmentOpen(Attachment attachment)
{
var extension = Path.GetExtension(attachment.fileName);
var mimeType = MimeTypeHelper.GetMimeType(extension);
byte[] DownloadFileBytes = ReadFile(attachment.Path);
await JSRuntime.InvokeVoidAsync("openFile", attachment.fileName, FileBytes, mimeType);
}