title: AWS. Storing and displaying the profile picture of users
body: <p>I have a requirement of storing andd displaying the profile picture of my users. So I used the S3.upload function in my nodeJs backend to store the image. 
  And after the image is stored I stored the link in database  to fetch it using <strong>ng-source</strong> in my view. It worked but the link got <strong>expired</strong> after few hours and did not work. Below is the code for my upload. <strong>Is there any solution in how to do this</strong> or <strong>any other better way to do this</strong>.</p>
  
  <pre><code>   var body = fs.createReadStream(file.file.path);
  
        //Upload the photo to AWS
  
        s3.upload({Body: body}, function (err, data) {
          if (err) {
            res.sendStatus(500);
          }
          if (data) {
  
          //getSignedUrl and Store it in Database
            var AWS = require('aws-sdk');
            var url =  req.params.doctorId +  "/Images/"  + fileName;
            var s3 = new AWS.S3()
                ,params = {Bucket: S3Bucket, Key:url };
            s3.getSignedUrl('getObject', params, function (err, url) {
              if (err || url == null) res.status(500).send({msg: "amazon s3 error"});
              else if (url) {
                if(req.body.picture == 1) {
                  User.findByIdAndUpdate(req.params.doctorId, {$set: {'FileName.profilePicture': url}},
                      function (err, doc) {
                        if (err)
                          res.sendStatus(500);
                        else
                          res.send({url: url});
                      });
  </code></pre>