[英]How do I convert readable image stream into base64 without saving locally
I want to convert an image in azure to base64. 我想将azure中的图像转换为base64。 How can I achieve this using azure-storage package?
如何使用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);
}
});
The response I get is like this, I want to convert this(octet/stream) to base64. 我得到的响应是这样的,我想将此(八位位组/流)转换为base64。
尝试
var dataUrl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAA.."; var buffer = new Buffer(dataUrl.split(",")[1], 'base64');
There is no built-in Node.js method to do that. 没有内置的Node.js方法可以做到这一点。 Some 3rd npm packages you can use, for example, https://www.npmjs.com/package/base64-stream
您可以使用一些第三个npm软件包,例如https://www.npmjs.com/package/base64-stream
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.