我无法将 http.get 图像转换为 base 64 [英] I am unable to convert http.get image into base 64

查看:27
本文介绍了我无法将 http.get 图像转换为 base 64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

app.getImage = function() {

    var image = Meteor.http.get("https://turtlerock-discourse.global.ssl.fastly.net/user_avatar/talk.turtlerockstudios.com/takran/45/879.png", {

    });
    var prefix = "data:image/png;base64,";
    var imagebase64 = new Buffer(image.content, 'binary').toString('base64');
    imagebase64 = prefix + imagebase64;

    console.log(imagebase64);
    return imagebase64;
}

但我没有看到结果,有什么帮助吗?这是错误的虚拟文本.

but I am not seeing results, any help? This is a dummy text for the error.

推荐答案

一个纯粹的 Meteor 解决方案:

a pure Meteor solutions:

    var response = HTTP.call('GET', url,{npmRequestOptions: { encoding: null }})

    var data = "data:" + response.headers["content-type"] + ";base64," + new Buffer(response.content).toString('base64');

这篇关于我无法将 http.get 图像转换为 base 64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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