def download_chunks(file_handler=None, ret_buffer=None):
    'Write to a buffer or to a file handler'
    chunk_size = (1024 if (not file_path) else (1024 * 100))
    download_size = 0
    last_progress = None
    for data in response.iter_content(chunk_size):
        download_size += len(data)
        if (ret_buffer is not None):
            ret_buffer.extend(data)
        if (file_handler is not None):
            file_handler.write(to_file_bytes(data))
        if self.output:
            units = progress_units(download_size, total_length)
            progress = human_readable_progress(download_size, total_length)
            if (last_progress != units):
                print_progress(self.output, units, progress)
                last_progress = units
    return download_size
Write to a buffer or to a file handler
def download_chunks(file_handler=None, ret_buffer=None):
    
    chunk_size = (1024 if (not file_path) else (1024 * 100))
    download_size = 0
    last_progress = None
    for data in response.iter_content(chunk_size):
        download_size += len(data)
        if (ret_buffer is not None):
            ret_buffer.extend(data)
        if (file_handler is not None):
            file_handler.write(to_file_bytes(data))
        if self.output:
            units = progress_units(download_size, total_length)
            progress = human_readable_progress(download_size, total_length)
            if (last_progress != units):
                print_progress(self.output, units, progress)
                last_progress = units
    return download_size