#NEWLINE# def put( self , data , **kwargs ) : #NEWLINE# #INDENT# 'Put data in GridFS as a new file.\n\n        Equivalent to doing::\n\n          try:\n              f = new_file(**kwargs)\n              f.write(data)\n          finally:\n              f.close()\n\n        `data` can be either an instance of :class:`str` (:class:`bytes`\n        in python 3) or a file-like object providing a :meth:`read` method.\n        If an `encoding` keyword argument is passed, `data` can also be a\n        :class:`unicode` (:class:`str` in python 3) instance, which will\n        be encoded as `encoding` before being written. Any keyword arguments\n        will be passed through to the created file - see\n        :meth:`~gridfs.grid_file.GridIn` for possible arguments. Returns the\n        ``"_id"`` of the created file.\n\n        If the ``"_id"`` of the file is manually specified, it must\n        not already exist in GridFS. Otherwise\n        :class:`~gridfs.errors.FileExists` is raised.\n\n        :Parameters:\n          - `data`: data to be written as a file.\n          - `**kwargs` (optional): keyword arguments for file creation\n\n        .. versionchanged:: 3.0\n           w=0 writes to GridFS are now prohibited.\n        ' #NEWLINE# grid_file = GridIn ( self . __collection , ** kwargs ) #NEWLINE# try : #NEWLINE# #INDENT# grid_file . write ( data ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# grid_file . close ( ) #NEWLINE# #UNINDENT# return grid_file . _id