import io


def stream_binary(f):
    """
    Create a data stream from a file path (str), raw bytes, or stream.
    """
    if isinstance(f, str):
        return open(f, "rb")

    if isinstance(f, bytes):
        return io.BytesIO(f)

    if hasattr(f, "read"):
        if hasattr(f, "seek"):
            f.seek(0)
        return f