如何使用剃刀组件将byte []保存到文件客户端

时间:2019-04-11 15:06:43

标签: c# blazor razor-components

我想通过字节[]在客户端上保存文件。

我已经尝试使用以下JS:

function saveToFile(name, arr) {
    var byteArray = new Uint8Array(arr);
    var a = window.document.createElement('a');

    a.href = window.URL.createObjectURL(new Blob([byteArray], { type: 'application/octet-stream' }));
    a.download = name;
    document.body.appendChild(a);
    a.click();

    document.body.removeChild(a);
}

并在组件内部调用:

JSRuntime.Current.InvokeAsync<object>("saveToFile", fileName, file.file);

这当前有效,但是对于〜20MB的文件,当我直接在本地主机上对其进行测试时,它需要60到90秒。

0 个答案:

没有答案
相关问题