title: saving picture to mongodb
body: <p>am trying yo do this using tornado and pil and mongodb.</p>
  
  <pre class="lang-py prettyprint-override"><code>avat = self.request.files['avatar'][0]["body"]
  nomfich = self.request.files['avatar'][0]["filename"]
  
  try:
      image = Image.open(StringIO.StringIO(buf=avat))
      size = image.size
      type = image.format
  
      avatar = r"/profile-images/{0}/{1}".format(pseudo, nomfich)
  
  except IOError:
      self.redirect("/erreur-im")
  </code></pre>
  
  <p>and the database code:</p>
  
  <pre class="lang-py prettyprint-override"><code>user={
      "pseudo": pseudo, 
      "password":password, 
      "email":email, 
      "tel":tel, 
      "commune":commune,    
      "statut":statut, 
      "nom":nom, 
      "prenom":prenom, 
      "daten":daten, 
      "sexe":sexe, 
      "avatar":avatar
  }
  
  self.db.essog.insert(user)  
  </code></pre>
  
  <p>and it worked ok, the "avatar" is saved, but there in no image, it saves only a name!</p>
  
  <p>my problem is:</p>
  
  <ul>
  <li>to understand how database deals with pictures, must i make image.save(path, format), but the path, is it a path of a normal system path (windows, or linux)?</li>
  <li>the profile is simple, and i've limited the picture upload to 500ko, and the document in mongodb is 16mb, so the document will handle the entire profile, but must i use gridFS even for small document when it contains picture?
  the key problem is in path of the picture saving, am stuck, and it's the first time i deal with database, so am sorry for that question.</li>
  </ul>