async def METHOD_NAME(req):
    """
    Upload an index file.
    Uploads a new index file.
    """
    index_id = req.match_info["index_id"]
    name = req.match_info["filename"]
    if name not in INDEX_FILE_NAMES:
        raise NotFound("Index file not found")
    try:
        reference = await get_data_from_req(req).index.get_reference(index_id)
    except ResourceNotFoundError:
        raise NotFound
    file_type = check_index_file_type(name)
    try:
        index_file = await get_data_from_req(req).index.upload_file(
            reference.id, index_id, file_type, name, req.multipart
        )
    except ResourceConflictError:
        raise HTTPConflict(text="File name already exists")
    return json_response(
        index_file,
        headers={"Location": f"/indexes/{index_id}/files/{name}"},
        status=201,
    )