download_if_needed#
- download_if_needed(uri: str, download_dir: Optional[str] = None, fs: Optional[FileSystem] = None, use_cache: bool = True) str [source]#
Download a file into a directory if it’s remote.
If uri is local, there is no need to download the file.
- Parameters
uri (str) – URI of file to download.
download_dir (Optional[str], optional) – Local directory to download file into. If None, the file will be downloaded to cache dir as defined by RVConfig. Defaults to None.
fs (Optional[FileSystem], optional) – If provided, use fs instead of the automatically chosen FileSystem for uri. Defaults to None.
use_cache (bool, optional) – If False and the file is remote, download it regardless of whether it exists in cache. Defaults to True.
- Returns
Path to local file.
- Return type
- Raises
NotReadableError if URI cannot be read from –