def pump_string_file(bytes, file_handle, segment_size=None):
    """Write bytes to file_handle in many smaller writes.

    :param bytes: The string to write.
    :param file_handle: The file to write to.
    """
    if not segment_size:
        segment_size = 5242880
    offsets = range(0, len(bytes), segment_size)
    view = memoryview(bytes)
    write = file_handle.write
    for offset in offsets:
        write(view[offset:offset + segment_size])
