Class: QgsFileDownloader

class qgis.core.QgsFileDownloader

Bases: PyQt5.QtCore.QObject

QgsFileDownloader is 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

New in version 3.0.

QgsFileDownloader(url: QUrl, outputFileName: str, authcfg: str = ‘’, delayStart: bool = False, httpMethod: Qgis.HttpMethod = Qgis.HttpMethod.Get, data: Union[QByteArray, bytes, bytearray] = QByteArray()) QgsFileDownloader

Parameters
  • url – the download URL

  • outputFileName – file name where the downloaded content will be stored

  • authcfg – optionally apply this authentication configuration

  • delayStart – if True, the download will not be commenced immediately and must be triggered by a later call to startDownload(). 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 – Method for the HTTP request : GET or POST, since QGIS 3.22

  • data

    If the request is POST, some data can be added, since QGIS 3.22

    Methods

    cancelDownload

    Call to abort the download and delete this object after the cancellation has been processed.

    childEvent

    connectNotify

    customEvent

    disconnectNotify

    isSignalConnected

    receivers

    sender

    senderSignalIndex

    startDownload

    Called to start the download

    timerEvent

    Signals

    downloadCanceled

    Emitted when the download was canceled by the user.

    downloadCompleted

    Emitted when the download has completed successfully [signal]

    downloadError

    Emitted when an error makes the download fail [signal]

    downloadExited

    Emitted always when the downloader exits [signal]

    downloadProgress

    Emitted when data are ready to be processed [signal]

cancelDownload(self)

Call to abort the download and delete this object after the cancellation has been processed.

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
downloadCanceled

Emitted when the download was canceled by the user.

See also

cancelDownload() [signal]

downloadCompleted

Emitted when the download has completed successfully [signal]

Parameters

url (QUrl) –

downloadError

Emitted when an error makes the download fail [signal]

Parameters

errorMessages (Iterable[str]) –

downloadExited

Emitted always when the downloader exits [signal]

downloadProgress

Emitted when data are ready to be processed [signal]

Parameters
  • bytesReceived (int) –

  • bytesTotal (int) –

isSignalConnected(self, QMetaMethod) bool
receivers(self, PYQT_SIGNAL) int
sender(self) QObject
senderSignalIndex(self) int
startDownload(self)

Called to start the download

timerEvent(self, QTimerEvent)