javascript – 如何在不保存本地的情况下将可读图像流转换为base64
作者:互联网
我想将azure中的图像转换为base64.如何使用azure-storage包实现这一目标?
this.blobService.getBlobProperties(
'container',
path,
(err, properties, status)=> {
if (err) {
res.send(502, "Error fetching file: %s", err.message);
} else if (!status.isSuccessful) {
res.send(502, "The file %s does not exist", fileName)
} else {
res.header('Content-Type', properties['contentType']);
this.blobService.createReadStream('container', path,(error,response)=>{
}).pipe(res);
}
});
我得到的响应是这样的,我想将此(八位字节/流)转换为base64.
解决方法:
尝试
var dataUrl =“data:image / png; base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAA ..”;
var buffer = new Buffer(dataUrl.split(“,”)[1],’base64′);
标签:javascript,azure,node-js,azure-storage 来源: https://codeday.me/bug/20190910/1800051.html