简体   繁体   中英

How to make blob or File in NodeJs from base64 string

我的后端有base64图像字符串,现在我想使用https://github.com/nkzawa/socket.io-stream#sscreateblobreadstreamblob-options(它使用File或Blob),如何在Node.js中制作Blob?

In Node.js you don't have Blobs but Buffers. You can create a buffer from a base64 string like this:

var str = "iAAANS....SUVORK5CYII="; // <-- use real base64 string here
var buf = Buffer.from(str, "base64");

stream.write(buf);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM