0
我想使用hapi创建文件下载API。 没有使用res.download()
,如何使用reply()
?使用hapi从NodeJS服务器下载文件
我想使用hapi创建文件下载API。 没有使用res.download()
,如何使用reply()
?使用hapi从NodeJS服务器下载文件
你需要做一个缓冲区,然后设置的答复
let buf = new Buffer(xls, 'binary');
return reply(buf)
.encoding('binary')
.type('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
.header('content-disposition', `attachment; filename=test-${new Date().toISOString()}.xlsx;`);
头和编码