def _download_file(self, url: str, directory: Path) -> str:
        """Download a single file from an on-prem location, a DAAC data center.

        Parameters:
            url: the granule url
            directory: local directory

        Returns:
            A local filepath or an exception.
        """
        # If the get data link is an Opendap location
        if "opendap" in url and url.endswith(".html"):
            url = url.replace(".html", "")
        local_filename = url.split("/")[-1]
        path = directory / Path(local_filename)
        if not path.exists():
            try:
                original_session = self.get_requests_session()
                # This reuses the auth cookie, we make sure we only authenticate N threads instead
                # of one per file, see #913
                self._clone_session_in_local_thread(original_session)
                session = self.thread_locals.local_thread_session
                with session.get(url, stream=True, allow_redirects=True) as r:
                    r.raise_for_status()
                    with open(path, "wb") as f:
                        # Cap memory usage for large files at 1MB per write to disk per thread
                        # https://docs.python-requests.org/en/latest/user/quickstart/#raw-response-content
                        for chunk in r.iter_content(chunk_size=1024 * 1024):
                            f.write(chunk)
            except Exception as e:
                msg = f"Failed to download {url!r} to {path!r}: {e}"
                logger.error(msg)
                raise DownloadFailure(msg)
        else:
            logger.info(f"File {local_filename} already downloaded")
        return str(path)
Download a single file from an on-prem location, a DAAC data center.

        Parameters:
            url: the granule url
            directory: local directory

        Returns:
            A local filepath or an exception.
        
earthaccess/store.py