While uploading the image from mobile using Gridfs, image is not showing on the browser.
I use the following code to upload image :-
Meteor.call("createUser", userData, password, function(err, id){
if(err){
Bert.alert("Error while creating mentor user. ","danger");
}else{
if(file){
Images.insert(file, function(err, fileObj) {
if(err){
console.log(err);
Bert.alert("Error while uploading image. ","danger");
}else{
console.log("Success -> File Id: ->", fileObj._id);
}
Meteor.call("saveImage", fileObj._id, id);
window.location.href="/";
});
}else{
Meteor.call("defaultImage", id);
window.location.href="/";
}
}
});
Save image id in the profile of user:-
saveImage: function(fileId, id){
Meteor.users.update({_id: id},{
$set: { "profile.image": fileId }
});
}
code to display the image on page :-
this.data.images.map(function(img){
return (
<div key={img._id}>
<img src={img.url()} className="img-responsive" alt="Invalid Image" />
</div>
)
});
The code is working fine while uploading the image from web browser, but not on mobile browser.
Kindly help on the above issue.
Thanks.