from typing import BinaryIO
from typing import Optional


def get_location(reader: BinaryIO) -> Optional[str]:
    """Given a binary file-handle, try to extract the path/URL to the file."""
    return (
        getattr(reader, "name", None)
        or getattr(reader, "url", None)
        or getattr(reader, "geturl", lambda: None)()
    )