本文介绍了Node.js 不能创建 Blob?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 node.js 并将我的音频流式传输到我的 node.js 服务器.现在我在构建音频 blob 的过程中注意到:
I am working with node.js and I streamed my Audio to my node.js server.Now I noticed during the process of building the audio blob:
var audioBlob = new Blob([dataview], { type: 'audio/wav' });
我在新的 Blob 中得到了一个 ReferenceError.似乎不支持 Blob.如何创建一个我想用 node.js fs 模块保存的 blob.
That I get a ReferenceError at new Blob.It seems that Blob is not supported.How can I create a blob which I would like to save with node.js fs module.
谢谢各位!
推荐答案
这个问题的解决方案是创建一个可以在数组缓冲区和节点缓冲区之间转换的函数.:)
The Solution to this problem is to create a function which can convert between Array Buffers and Node Buffers. :)
将二进制 NodeJS 缓冲区转换为 JavaScript ArrayBuffer
在最近的节点版本中,它只是:
In recent node versions it's just:
let buffer = Buffer.from(arraybuffer);
let arraybuffer = Uint8Array.from(buffer).buffer;
这篇关于Node.js 不能创建 Blob?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!