Class: QgsFileDownloader¶
A utility class for downloading files.
To use this class, it is necessary to pass the URL and an output file name as arguments to the constructor, the download will start immediately.
The download is asynchronous.
The object will destroy itself when the request completes, errors or is canceled. An optional authentication configuration can be specified.
Note
This class was part of the GUI library from QGIS 2.18.1 until QGIS 3.0
Class Hierarchy¶
Base classes¶
Methods
Call to abort the download and delete this object after the cancellation has been processed. |
|
Called to start the download |
Signals
Emitted when the download was canceled by the user. |
|
Emitted when the download has completed successfully |
|
Emitted when an error makes the download fail |
|
Emitted always when the downloader exits |
|
Emitted when data are ready to be processed |
- class qgis.core.QgsFileDownloader[source]¶
Bases:
QObject
- __init__(url: QUrl, outputFileName: str | None, authcfg: str | None = '', delayStart: bool = False, httpMethod: Qgis.HttpMethod = Qgis.HttpMethod.Get, data: QByteArray | bytes | bytearray = QByteArray())
QgsFileDownloader
- Parameters:
url (QUrl) – the download URL
outputFileName (Optional[str]) – file name where the downloaded content will be stored
authcfg (Optional[str] = '') – optionally apply this authentication configuration
delayStart (bool = False) – if
True
, the download will not be commenced immediately and must be triggered by a later call tostartDownload()
. This can be useful if connections need to be made to the downloader and there’s a chance the download will emit signals before these connections have been made.httpMethod (Qgis.HttpMethod = Qgis.HttpMethod.Get) – Method for the HTTP request : GET or POST, since QGIS 3.22
data (Union[QByteArray, bytes, bytearray] = QByteArray()) – If the request is POST, some data can be added, since QGIS 3.22
- cancelDownload(self)[source]¶
Call to abort the download and delete this object after the cancellation has been processed.
See also
- signal downloadCompleted(url: QUrl)[source]¶
Emitted when the download has completed successfully
- Parameters:
url (QUrl)
- signal downloadError(errorMessages: List[str])[source]¶
Emitted when an error makes the download fail
- Parameters:
errorMessages (List[str])