#NEWLINE# def open_upload_stream( self , filename , chunk_size_bytes = None , metadata = None ) : #NEWLINE# #INDENT# 'Opens a Stream that the application can write the contents of the\n        file to.\n\n        The user must specify the filename, and can choose to add any\n        additional information in the metadata field of the file document or\n        modify the chunk size.\n        For example::\n\n          my_db = MongoClient().test\n          fs = GridFSBucket(my_db)\n          grid_in, file_id = fs.open_upload_stream(\n                "test_file", chunk_size_bytes=4,\n                metadata={"contentType": "text/plain"})\n          grid_in.write("data I want to store!")\n          grid_in.close()  # uploaded on close\n\n        Returns an instance of :class:`~gridfs.grid_file.GridIn`.\n\n        Raises :exc:`~gridfs.errors.NoFile` if no such version of\n        that file exists.\n        Raises :exc:`~ValueError` if `filename` is not a string.\n\n        :Parameters:\n          - `filename`: The name of the file to upload.\n          - `chunk_size_bytes` (options): The number of bytes per chunk of this\n            file. Defaults to the chunk_size_bytes in :class:`GridFSBucket`.\n          - `metadata` (optional): User data for the \'metadata\' field of the\n            files collection document. If not provided the metadata field will\n            be omitted from the files collection document.\n        ' #NEWLINE# validate_string ( 'filename' , filename ) #NEWLINE# opts = { #NEWLINE# #INDENT# 'filename' : filename , #NEWLINE# 'chunk_size' : ( chunk_size_bytes if ( chunk_size_bytes is not None ) else self . _chunk_size_bytes ) , #NEWLINE# #UNINDENT# } #NEWLINE# if ( metadata is not None ) : #NEWLINE# #INDENT# opts [ 'metadata' ] = metadata #NEWLINE# #UNINDENT# return GridIn ( self . _collection , ** opts )