0

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.

DivyaMenon
  • 311
  • 4
  • 19
  • 1
    Can you first check that the image loads when manually typing the image url in the address bar? – Wayne Ellery Jun 03 '15 at 06:52
  • Yes. I tried that. Its getting loaded. But it takes time. Its loading slowly only. – DivyaMenon Jun 03 '15 at 06:58
  • This issue is solved.. I had written all my code for fetching the image from MongoDB in my service which was called from a controller. When I wrote the code for fretching the image straight inside the controller, it worked. It's loading slowly but the image gets completed loaded in client-end. – DivyaMenon Jun 11 '15 at 08:39

0 Answers0