繁体   English   中英

NodeJS从base64提供图像

[英]NodeJS serve image from base64

我的流星应用程序上有一条路线:

    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'});

通过这条路线,我想从我的Mongo-Collection提供Userimages。 我的收藏img_base64有一个base64编码的图像,并将其保存到img_base64 我的问题是,我需要如何将base64变量作为png响应? 我需要类似this.response.end(img_base64,....) 谢谢你的帮助!

这实际上就是您所需要的(假设img_base64是一个字符串):

this.response.end(img_base64, 'base64');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM