code: def __flush(self):
          
          def on_md5(md5):
              self._file["md5"] = md5
              self._file["length"] = self._position
              self._file["uploadDate"] = datetime.datetime.utcnow()
              return self._coll.files.insert(self._file)
  
          return self.__flush_buffer()\
              .addCallback(lambda _: self._coll.filemd5(self._id))\
              .addCallback(on_md5)
docs: Flush the file to the database.