'Write a file to GridFS
Application developers should generally not need to
instantiate this class directly - instead see the methods
provided by :class:`~gridfs.GridFS`.
Raises :class:`TypeError` if `root_collection` is not an
instance of :class:`~pymongo.collection.Collection`.
Any of the file level options specified in the `GridFS Spec
<http://dochub.mongodb.org/core/gridfsspec>`_ may be passed as
keyword arguments. Any additional keyword arguments will be
set as additional fields on the file document. Valid keyword
arguments include:
- ``"_id"``: unique ID for this file (default:
:class:`~bson.objectid.ObjectId`) - this ``"_id"`` must
not have already been used for another file
- ``"filename"``: human name for the file
- ``"contentType"`` or ``"content_type"``: valid mime-type
for the file
- ``"chunkSize"`` or ``"chunk_size"``: size of each of the
chunks, in bytes (default: 255 kb)
- ``"encoding"``: encoding used for this file. In Python 2,
any :class:`unicode` that is written to the file will be
converted to a :class:`str`. In Python 3, any :class:`str`
that is written to the file will be converted to
:class:`bytes`.
:Parameters:
- `root_collection`: root collection to write to
- `**kwargs` (optional): file level options (see above)
.. versionchanged:: 3.0
`root_collection` must use an acknowledged
:attr:`~pymongo.collection.Collection.write_concern`'

def __init__(self, root_collection, **kwargs):

    if (not isinstance(root_collection, Collection)):
        raise TypeError('root_collection    must    be    an    instance    of    Collection')
    if (not root_collection.write_concern.acknowledged):
        raise ConfigurationError('root_collection    must    use    acknowledged    write_concern')
    if ('content_type' in kwargs):
        kwargs['contentType'] = kwargs.pop('content_type')
    if ('chunk_size' in kwargs):
        kwargs['chunkSize'] = kwargs.pop('chunk_size')
    coll = root_collection.with_options(read_preference=ReadPreference.PRIMARY)
    kwargs['md5'] = md5()
    kwargs['_id'] = kwargs.get('_id', ObjectId())
    kwargs['chunkSize'] = kwargs.get('chunkSize', DEFAULT_CHUNK_SIZE)
    object.__setattr__(self, '_coll', coll)
    object.__setattr__(self, '_chunks', coll.chunks)
    object.__setattr__(self, '_file', kwargs)
    object.__setattr__(self, '_buffer', StringIO())
    object.__setattr__(self, '_position', 0)
    object.__setattr__(self, '_chunk_number', 0)
    object.__setattr__(self, '_closed', False)
    object.__setattr__(self, '_ensured_index', False)
