Node.js无法创建Blob? [英] Node.js can't create Blobs?

查看:736
本文介绍了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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆