KGAPI2::Drive::FileAbstractResumableJob

Search for usage in LXR

KGAPI2::Drive::FileAbstractResumableJob Class Referenceabstract

#include <fileabstractresumablejob.h>

Inherits KGAPI2::Drive::FileAbstractDataJob.

Inherited by KGAPI2::Drive::FileResumableCreateJob, and KGAPI2::Drive::FileResumableModifyJob.

Signals

void readyWrite (KGAPI2::Drive::FileAbstractResumableJob *job)
 

Public Member Functions

 FileAbstractResumableJob (const AccountPtr &account, QObject *parent=nullptr)
 
 FileAbstractResumableJob (const FilePtr &metadata, const AccountPtr &account, QObject *parent=nullptr)
 
 FileAbstractResumableJob (QIODevice *device, const AccountPtr &account, QObject *parent=nullptr)
 
 FileAbstractResumableJob (QIODevice *device, const FilePtr &metadata, const AccountPtr &account, QObject *parent=nullptr)
 
 ~FileAbstractResumableJob () override
 
FilePtr metadata () const
 
void setUploadSize (int size)
 
void write (const QByteArray &data)
 

Protected Member Functions

virtual QUrl createUrl ()=0
 
void dispatchRequest (QNetworkAccessManager *accessManager, const QNetworkRequest &request, const QByteArray &data, const QString &contentType) override
 
void emitReadyWrite ()
 
void handleReply (const QNetworkReply *reply, const QByteArray &rawData) override
 
void start () override
 

Detailed Description

Abstract superclass for KGAPI2::Drive::File create or modify jobs that use chunked uploading of the file's content.

The Job starts an upload session and data is written in chunks. When the Job is out of chunks to write it will emit the readyWrite() signal and expect new data to be written via write().

Writing 0 bytes will indicate that the File has been completely transferred and the Job will close the upload session.

See also
Perform a resumable upload
readyWrite, write
Author
David Barchiesi david[email protected]@bar[email protected]chie.[email protected]si
Since
20.12

Definition at line 41 of file fileabstractresumablejob.h.

Constructor & Destructor Documentation

FileAbstractResumableJob::FileAbstractResumableJob ( const AccountPtr account,
QObject parent = nullptr 
)
explicit

Constructs a job that will upload an Untitled file in the users root folder.

Parameters
accountAccount to authenticate the request
parent

Definition at line 197 of file fileabstractresumablejob.cpp.

FileAbstractResumableJob::FileAbstractResumableJob ( const FilePtr metadata,
const AccountPtr account,
QObject parent = nullptr 
)
explicit

Constructs a job that will upload a file with its metadata.

Parameters
metadataFile metadata to upload
accountAccount to authenticate the request
parent

Definition at line 204 of file fileabstractresumablejob.cpp.

FileAbstractResumableJob::FileAbstractResumableJob ( QIODevice device,
const AccountPtr account,
QObject parent = nullptr 
)
explicit

Constructs a job that will upload an Untitled file in the users root folder with data contained in device.

Parameters
deviceOpen device to read from
accountAccount to authenticate the request
parent

Definition at line 213 of file fileabstractresumablejob.cpp.

FileAbstractResumableJob::FileAbstractResumableJob ( QIODevice device,
const FilePtr metadata,
const AccountPtr account,
QObject parent = nullptr 
)
explicit

Constructs a job that will upload a file with its metadata with data contained in device.

Parameters
deviceOpen device to read from
metadataFile metadata to upload
accountAccount to authenticate the request
parent

Definition at line 222 of file fileabstractresumablejob.cpp.

FileAbstractResumableJob::~FileAbstractResumableJob ( )
overridedefault

Destructor.

Member Function Documentation

virtual QUrl KGAPI2::Drive::FileAbstractResumableJob::createUrl ( )
protectedpure virtual

Generates url that will be used during upload session start.

void FileAbstractResumableJob::dispatchRequest ( QNetworkAccessManager accessManager,
const QNetworkRequest request,
const QByteArray data,
const QString contentType 
)
overrideprotectedvirtual

KGAPI2::Job::dispatchRequest implementation.

Parameters
accessManager
request
data
contentType

Implements KGAPI2::Job.

Definition at line 296 of file fileabstractresumablejob.cpp.

void FileAbstractResumableJob::emitReadyWrite ( )
protected

Emit readyWrite() signal.

Definition at line 394 of file fileabstractresumablejob.cpp.

void FileAbstractResumableJob::handleReply ( const QNetworkReply reply,
const QByteArray rawData 
)
overrideprotectedvirtual

KGAPI2::Job::handleReply implementation.

Parameters
reply
rawData

Implements KGAPI2::Job.

Definition at line 316 of file fileabstractresumablejob.cpp.

FilePtr FileAbstractResumableJob::metadata ( ) const

Returns metadata supplied at Job creation or retrieved on Job completion.

Definition at line 235 of file fileabstractresumablejob.cpp.

void KGAPI2::Drive::FileAbstractResumableJob::readyWrite ( KGAPI2::Drive::FileAbstractResumableJob job)
signal

Emitted when job requires more data to proceed.

Bytes should be written via write(). When connecting to this signal always use a synchronous connection type like Qt::DirectConnection.

Subclasses should never ever emit this signal directly.

Parameters
jobThe job that requires data
See also
readyWrite()
Note
Connecting via Qt::QueuedConnection or any other asynchronous connection type will potentially crash the job or end it prematurely. Use Qt::DirectConnection
See also
write
void FileAbstractResumableJob::setUploadSize ( int  size)

Sets the total upload size and is required for progress reporting via the Job::progress() signal.

Definition at line 240 of file fileabstractresumablejob.cpp.

void FileAbstractResumableJob::start ( )
overrideprotectedvirtual

KGAPI2::Job::start implementation.

Implements KGAPI2::Job.

Definition at line 283 of file fileabstractresumablejob.cpp.

void FileAbstractResumableJob::write ( const QByteArray data)

This function writes all the bytes in data to the upload session.

The write operation splits written data in chunks that will be subsequently uploaded in the session.

Writing an empty data wil signal the Job that it can complete as no more data will be written.

When more data is required the readyWrite() signal is emitted.

See also
readyWrite
Parameters
datathe data to write

Definition at line 250 of file fileabstractresumablejob.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Jun 18 2021 23:10:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.