I have created a Node-Webkit
application using AngularJS
in front-end and NodeJS
in backend. I am trying to load an image into my application. It works fine if the internet is fast. But at times,if internet is slow it doesn't get loaded. I couldn't figure out what the issue is. Whenever I want to load an image I call a service to my node server, and from the node server it loads and sends image from MongoDB
.
Here is my code to load image from DB:
var profilePicture = require('skipper-gridfs')({
uri: 'mongodb://' + config.fileUploadDownload.url + ':27017/' + config.fileUploadDownload.db + '.Media'
});
profilePicture.read(params, function (err, downloadedFile) {
if (err) {
res.send("found an error");
} else {
res.setHeader('content-type', 'image/png');
res.send(downloadedFile);
}
});
And this is my code for rendering the image in HTML:
<img ng-src="{{img_url}}" class="prof-ico">
//img_url
is the url to download image from backend
Can anyone help me in solving this issue?
Thanks in advance.