def METHOD_NAME(
    state: "State",
    host: "Host",
    remote_filename,
    filename_or_io,
    remote_temp_filename=None,  # ignored
    print_output: bool = False,
    print_input: bool = False,
    **command_kwargs,
):
    """
    Download a local file by copying it to a temporary location and then writing
    it to our filename or IO object.
    """
    _, temp_filename = mkstemp()
    try:
        # Copy the file using `cp` such that we support sudo/su
        status, _, stderr = run_shell_command(
            state,
            host,
            "cp {0} {1}".format(remote_filename, temp_filename),
            print_output=print_output,
            print_input=print_input,
            **command_kwargs,
        )
        if not status:
            raise IOError("\n".join(stderr))
        # Load our file or IO object and write it to the temporary file
        with open(temp_filename, encoding="utf-8") as temp_f:
            with get_file_io(filename_or_io, "wb") as file_io:
                data_bytes: bytes
                data = temp_f.read()
                if isinstance(data, str):
                    data_bytes = data.encode()
                else:
                    data_bytes = data
                file_io.write(data_bytes)
    finally:
        os.remove(temp_filename)
    if print_output:
        click.echo(
            "{0}file copied: {1}".format(host.print_prefix, remote_filename),
            err=True,
        )
    return True