[英]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.