title: Retrieve image from mongoDB
body: <p>I am using <strong>gridfs</strong>, so I have in my monDB:</p>
  
  <pre><code>fs.chunks:
  
  {
          "_id" : ObjectId("542e684a8a1cec178a172673"),
          "n" : 1,
          "data" : BinData(0,"2N6DSSfbCN/LLacNDYrJUQDEZgimMUwFpQGoJP0RU19Bi4PM82DjrUnKhE/P9v7P8ZveD1oDpFBM0iml9NE3WQmAvYFoG+nhD73Jm4N9b4LpylaAN5Ef+gVdgGSTAfSUwOikXoVick5pSQCkRmTCU5NT9VVfjHdAx74/ZhFRj+TIRjzlAhzkACBElzgMwGCo7tX+FYrpQLJ5KRmXiwFFwsNtHHzXiK1eu+CG1FumhGpA/qdG8CdDgD1xUHEcerMGO/eLGR9ML7ni/VjXxWzqp2j5DG2/WuKNv7xd3Kz/vr0MctJhuaBIl35YrKhdLnzqDa0uDa6bm4jz+eNyAI2hQbayGo4kVPFe8W7wFpY7qfBvnB9kbocxfZSdADDUNwYaydpT8lIcKEN9XfQJOYZvHp0El"),
          "files_id" : ObjectId("542e684a8a1cec178a172671")
  }
  
  fs.files:
  
  {
          "_id" : ObjectId("542e65378axdeckhb0"),
          "uploadDate" : ISODate("2012-11-01"),
          "length" : 15673,
          "chunkSize" : 33222,
          "md5" : "f66e6654854a28e3672cfhds334d223b55a1"
  }
  </code></pre>
  
  <p>I am doing:</p>
  
  <pre><code>var fileId = mongoose.Types.ObjectId(id);
  var gridStore = new GridStore(db, fileId, 'r');
  
  gridStore.open(function (err, gridStore) {
     console.log(gridStore.uploadDate);
  });
  </code></pre>
  
  <p>I got :</p>
  
  <pre><code>2012-11-01
  </code></pre>
  
  <p>BUT I want to <strong>display images</strong>
  I tried something like that but it is not clear at all:</p>
  
  <pre><code> app.get('/data/:imgtag', function(req, res) {
  
          fileRepository.getFile( function(error,data) {
          res.writeHead('200', {'Content-Type': 'image/png'});
          res.end(data,'binary');
          },    req.params.imgtag
          );
  });
  
  app.listen(3000);
  </code></pre>
  
  <p>Thanks for your help!</p>