def max_chunk_size_generator(chunk_size, file_data):
    """
    Generate chunks by defining a maximum chunk size

    :param chunk_size: Maximum chunk size allow
    :param file_data: bytes data
    :return:
    """
    try:
        file_len = len(file_data)
    except TypeError:
        file_len = get_file_size(file_data)
    chunk_count, final_chunk = divmod(file_len, chunk_size)
    if final_chunk:
        chunk_count += 1
    return chunk_generator(chunk_count, chunk_size, file_data)

    Generate chunks by defining a maximum chunk size

    :param chunk_size: Maximum chunk size allow
    :param file_data: bytes data
    :return:
    
instagram_private_api/utils.py