class documentation
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 used for HTTP and HTTPS downloads. |
| Static Method | _path |
Undocumented |
| Static Method | _remove |
Undocumented |
| Static Method | _validate |
Undocumented |
| Method | _download |
Undocumented |
Create a remote file downloader.
| Parameters | |
apiRemoteFileAPIClient | None | Optional 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:str | Source URL. Supported schemes are file, http, https, gcs, gs, and s3. |
destination:Path | Local destination path. |
timeout:float | HTTP request timeout in seconds. |
validatebool | Whether to validate image content and format compatibility after download. |
| Returns | |
Path | Local destination path. |
| Raises | |
ValueError | If 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. |
def _download_to_temporary_path(self, url:
str, destination: Path, *, scheme: str, timeout: float):
¶
Undocumented