1 回答

TA貢獻(xiàn)1777條經(jīng)驗 獲得超10個贊
只需將緩沖區(qū)發(fā)送到客戶端并使用此函數(shù)下載文件(React 示例代碼):
prepareDocForDownload = result => {
const length = Object.entries(result.data).length;
let bytes = new Uint8Array(length);
for (let i=0; i<length; i++) {
bytes[i] = result.data[i];
}
const file = new Blob(
[bytes.buffer],
{type: 'application/pdf'});
const fileURL = URL.createObjectURL(file);
const link = document.createElement('a');
link.href = fileURL;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
link.click();
};
- 1 回答
- 0 關(guān)注
- 115 瀏覽
添加回答
舉報