FileDownloader
Class to downloader external files. for now it only supports http(s) protocol. If a message dispatcher is provided, it will automatically log the download progress and the time it took to download the file.
Attributes
destination_folder: str
message_dispatcher: MessageDispatcher
Functions
Initialize self. See help(type(self)) for accurate signature.
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
destination_folder | str | ||
message_dispatcher | MessageDispatcher |
Unzip a file to a given path
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
file_path | str | The path to the file to unzip `` | |
destination_folder | str |
Return type:
str |
Download a file from a given url to a given file path
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
url | str | The url to download the file from `` | |
filename | str | ||
headers | Dict | The headers to send with the request `dict` | |
timeout | float | The timeout for the request `` | |
destination_folder | str | The destination folder to save the file to, if none, the default destination folder is used `` |
Return type:
str |
Download a file from a given url if the file does not already exist. This class is useful for downloading a file that is required for a task. If used within a task, it automatically logs the download progress and the time it took to download the file.
tries to download a file with the same name, it considers that the file has already been downloaded
and will not download it. If you want to force the download of a file (new version for example), change the filename (adding v2 for example).
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
url | str | Url to download the file from | |
filename | str | Name of the file once downloaded. this filename must be unique for the brick. if a file downloader | |
headers | Dict | Http header to attach to the download request, defaults to none [str, str], optional | |
timeout | float | Timeout of the download request, defaults to none , optional | |
decompress_file | bool | False | If true the file is decompress (support .zip and .tar.gz) after the download and the zip file is deleted, defaults to false , optional |
Return type:
str |