code: def put(self, data, **kwargs):
          
          grid_file = GridIn(self.__collection, **kwargs)
  
          def _finally(result):
              return grid_file.close().addCallback(lambda _: result)
  
          return grid_file.write(data)\
              .addBoth(_finally)\
              .addCallback(lambda _: grid_file._id)
docs: Put data in GridFS as a new file.
  
          Equivalent to doing:
  
          >>> f = new_file(**kwargs)
          >>> try:
          >>>     f.write(data)
          >>> finally:
          >>>     f.close()
  
          `data` can be either an instance of :class:`str` or a
          file-like object providing a :meth:`read` method. Any keyword
          arguments will be passed through to the created file - see
          :meth:`~gridfs.grid_file.GridIn` for possible
          arguments. Returns the ``"_id"`` of the created file.
  
          :Parameters:
            - `data`: data to be written as a file.
            - `**kwargs` (optional): keyword arguments for file creation
  
          .. versionadded:: 1.6