[英]How do I transfer base64 data into a readable image stream without saving locally
[英]How do I convert readable image stream into base64 without saving locally
我想將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');
沒有內置的Node.js方法可以做到這一點。 您可以使用一些第三個npm軟件包,例如https://www.npmjs.com/package/base64-stream
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.