class documentation

class RemoteFileDownloader:

Constructor: RemoteFileDownloader(api_client)

View In Hierarchy

Download remote files with optional image validation.

Method __init__ Create a remote file downloader.
Method download Download a file to destination.
Instance Variable api_client Client used for HTTP and HTTPS downloads.
Static Method _path_from_file_url Undocumented
Static Method _remove_temporary_file Undocumented
Static Method _validate_image_format Undocumented
Method _download_to_temporary_path Undocumented
def __init__(self, api_client: RemoteFileAPIClient | None = None):

Create a remote file downloader.

Parameters
api_client:RemoteFileAPIClient | NoneOptional client used for HTTP and HTTPS downloads. If omitted, RequestsRemoteFileAPIClient is used.
def download(self, url: str, destination: Path, *, timeout: float = 30.0, validate_image: bool = False) -> Path:

Download a file to destination.

Existing destination files are reused. When validate_image is true, both reused and newly downloaded files are checked with Pillow and the destination suffix.

Parameters
url:strSource URL. Supported schemes are file, http, https, gcs, gs, and s3.
destination:PathLocal destination path.
timeout:floatHTTP request timeout in seconds.
validate_image:boolWhether to validate image content and format compatibility after download.
Returns
PathLocal destination path.
Raises
ValueErrorIf the URL scheme is unsupported, the destination image suffix is unsupported, the downloaded file is not a valid image, or the image format does not match the suffix.
api_client =

Client used for HTTP and HTTPS downloads.

@staticmethod
def _path_from_file_url(url: str) -> Path:

Undocumented

@staticmethod
def _remove_temporary_file(path: Path):

Undocumented

@staticmethod
def _validate_image_format(path: Path, *, destination: Path | None = None):

Undocumented

def _download_to_temporary_path(self, url: str, destination: Path, *, scheme: str, timeout: float):

Undocumented