title: Get data from GridFS using mongoengine
body: <p>dear colleagues.<br>
  In my project I have successfully saved data(image) in mongodb using mongoengine. I have problem with getting image from mongodb and displaying it on the client. I'm not using local storage, so this is causing the problem with loading the page (the page will not be shown until <b> photo_view </b> function has been loaded the file and stored to temp file.</p>
  
  <p>This is a short cut of my saved object in mongodb</p>
  
  <pre><code>{
      "_id" : ObjectId("53c123edcb596046fdf6c746"),
      "main_photo" : ObjectId("53c123e1cb596046fdf6c6fc"),
      "create_date" : ISODate("2014-07-12T12:02:41.036Z")
  }
  </code></pre>
  
  <p>The actual file is saved in <b> db.fs.files </b> using GridFS.<br><br>
  This is the models.py file</p>
  
  <pre><code>class Photo(Document):
      def __unicode__(self):
          return self.create_date
      main_photo = FileField()
      create_date = DateTimeField(default=datetime.datetime.now)
  </code></pre>
  
  <p>The problem is in <b>photo_view</b> function</p>
  
  <pre><code>@login_required
  def photo_view(request, id, template_name):
      params = {}
      obj = Photo.objects.get(id = id)
      print obj.main_photo.read()
      params['object'] = obj
      return render(request, template_name, params)
  </code></pre>
  
  <p>The <b> obj.main_photo.read() </b> is an actual file. How can I achieve in loading page without storing data in temporary file on my server. Even if I will load the data, the function <b> photo_view </b> will not finish until it is loaded/copied from <b> GridFS </b>. </p>