Reputation: 822
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.
I have a base64 encoded image in my Collection and saving it to varibale img_base64
.
My Question is, what do I need to do with my base64 variable to respond it as a png?
I need somthing like this.response.end(img_base64,....)
.
Thanks for your help!
Upvotes: 0
Views: 658
Reputation: 106698
That's literally all you need (assuming img_base64
is a string):
this.response.end(img_base64, 'base64');
Upvotes: 3