'Store a file in a index'

def put_file(self, filename, index, doc_type, id=None, name=None):

    if (id is None):
        request_method = 'POST'
    else:
        request_method = 'PUT'
    path = make_path(index, doc_type, id)
    doc = file_to_attachment(filename)
    if name:
        doc['_name'] = name
    return self._send_request(request_method, path, doc)
