如何在不保存本地的情况下将可读图像流转换为base64 [英] How do I convert readable image stream into base64 without saving locally

查看:147
本文介绍了如何在不保存本地的情况下将可读图像流转换为base64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将azure中的图像转换为base64.如何使用azure-storage软件包实现此目标?

I want to convert an image in azure to base64. How can I achieve this using azure-storage package?

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.

The response I get is like this, I want to convert this(octet/stream) to base64.

推荐答案

没有内置的Node.js方法可以做到这一点.您可以使用一些第三个npm软件包,例如, https://www.npmjs.com/package/base64-stream

There is no built-in Node.js method to do that. Some 3rd npm packages you can use, for example, https://www.npmjs.com/package/base64-stream

这篇关于如何在不保存本地的情况下将可读图像流转换为base64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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