[英]NodeJS serve image from base64
I have a Route on my Meteor App: 我的流星应用程序上有一条路线:
this.route("/userimg/:id", function(){
console.log("hello");
img_base64 = Meteor.users.findOne(this.params.id).userimage;
this.response.writeHead(200, {'Content-Type': 'image/png' });
},{where: 'server'});
With this Route I want to serve Userimages from my Mongo-Collection. 通过这条路线,我想从我的Mongo-Collection提供Userimages。 I have a base64 encoded image in my Collection and saving it to varibale
img_base64
. 我的收藏
img_base64
有一个base64编码的图像,并将其保存到img_base64
。 My Question is, what do I need to do with my base64 variable to respond it as a png? 我的问题是,我需要如何将base64变量作为png响应? I need somthing like
this.response.end(img_base64,....)
. 我需要类似
this.response.end(img_base64,....)
。 Thanks for your help! 谢谢你的帮助!
这实际上就是您所需要的(假设img_base64
是一个字符串):
this.response.end(img_base64, 'base64');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.