我有一个使用 XMLHTTPResponse 的客户端表单,它允许我获取保存为文件的响应数据。在其余的 blob 转换发生之前,它将响应类型设置为 arraybuffer,如下所示:
xhr.responseType = "arraybuffer";
我一直在搜索并找到多种创建数组缓冲区的方法,但没有详细说明如何将节点中的响应带到数组缓冲区。我正在使用 unirest 如下:
unirest.post('http://myvendorsapi/Upload_PDF')
.headers({ 'Content-Type': 'multipart/form-data' })
.field('filename', filename)// Form field
.attach('file', fileloc)// Attachment
.end(function (response) {
console.log(response);
var returnfile = response.body;
// Need logic to convert to arraybuffer
});
如何将响应类型设置为 arraybuffer 或将响应转换为 arraybuffer?