KIO::StoredTransferJob Class

class KIO::StoredTransferJob

StoredTransferJob is a TransferJob (for downloading or uploading data) that also stores a QByteArray with the data, making it simpler to use than the standard TransferJob. More...

Header: #include <KIO/StoredTransferJob>
CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
target_link_libraries(mytarget PRIVATE KF6::KIOCore)
Inherits: KIO::TransferJob

Public Functions

QByteArray data() const
void setData(const QByteArray &arr)
KIO::StoredTransferJob *storedGet(const QUrl &url, KIO::LoadType reload = NoReload, KIO::JobFlags flags = DefaultFlags)
KIO::StoredTransferJob *storedHttpPost(const QByteArray &arr, const QUrl &url, KIO::JobFlags flags = DefaultFlags)
KIO::StoredTransferJob *storedHttpPost(QIODevice *device, const QUrl &url, qint64 size = -1, KIO::JobFlags flags = DefaultFlags)
(since 5.10) KIO::StoredTransferJob *storedPut(QIODevice *input, const QUrl &url, int permissions, KIO::JobFlags flags = DefaultFlags)
KIO::StoredTransferJob *storedPut(const QByteArray &arr, const QUrl &url, int permissions, KIO::JobFlags flags = DefaultFlags)

Detailed Description

For KIO::storedGet it puts the data into the member QByteArray, so the user of this class can get hold of the whole data at once by calling data() when the result signal is emitted. You should only use StoredTransferJob to download data if you cannot process the data by chunks while it's being downloaded, since storing everything in a QByteArray can potentially require a lot of memory.

For KIO::storedPut the user of this class simply provides the bytearray from the start, and the job takes care of uploading it. You should only use StoredTransferJob to upload data if you cannot provide the in chunks while it's being uploaded, since storing everything in a QByteArray can potentially require a lot of memory.

Member Function Documentation

QByteArray StoredTransferJob::data() const

Get hold of the downloaded data. This is for get jobs. You're supposed to call this only from the slot connected to the result() signal.

See also setData().

void StoredTransferJob::setData(const QByteArray &arr)

Set data to be uploaded. This is for put jobs. Automatically called by KIO::storedPut(const QByteArray &, ...), do not call this yourself.

See also data().

Related Non-Members

KIO::StoredTransferJob *storedGet(const QUrl &url, KIO::LoadType reload = NoReload, KIO::JobFlags flags = DefaultFlags)

Get (means: read), into a single QByteArray.

url the URL of the file

reload Reload to reload the file, NoReload if it can be taken from the cache

flags Can be HideProgressInfo here

Returns the job handling the operation.

KIO::StoredTransferJob *storedHttpPost(const QByteArray &arr, const QUrl &url, KIO::JobFlags flags = DefaultFlags)

HTTP POST (means: write) data from a single QByteArray.

arr The data to write

url Where to write data.

flags Can be HideProgressInfo here.

Returns the job handling the operation.

KIO::StoredTransferJob *storedHttpPost(QIODevice *device, const QUrl &url, qint64 size = -1, KIO::JobFlags flags = DefaultFlags)

HTTP POST (means: write) data from the given IO device.

device Device from which the encoded data to be posted is read. Must be open for reading.

url Where to write data.

size Size of the encoded data to be posted.

flags Can be HideProgressInfo here.

Returns the job handling the operation.

[since 5.10] KIO::StoredTransferJob *storedPut(QIODevice *input, const QUrl &url, int permissions, KIO::JobFlags flags = DefaultFlags)

Put (means: write) data from a QIODevice.

input The data to write, a device to read from. Must be open for reading (data will be read from the current position).

url Where to write data.

permissions May be -1. In this case no special permission mode is set.

flags Can be HideProgressInfo, Overwrite and Resume here. WARNING: Setting Resume means that the data will be appended to dest if dest exists.

Returns the job handling the operation.

This function was introduced in 5.10.

KIO::StoredTransferJob *storedPut(const QByteArray &arr, const QUrl &url, int permissions, KIO::JobFlags flags = DefaultFlags)

Put (means: write) data from a single QByteArray.

arr The data to write

url Where to write data.

permissions May be -1. In this case no special permission mode is set.

flags Can be HideProgressInfo, Overwrite and Resume here. WARNING: Setting Resume means that the data will be appended to dest if dest exists.

Returns the job handling the operation.