2017-07-06 01:59:00 +03:00
|
|
|
#ifndef IMAGEUPLOADER_H
|
|
|
|
#define IMAGEUPLOADER_H
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
|
|
|
class QNetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
|
|
|
|
|
|
|
class ImageUploader : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
|
|
|
|
|
|
|
|
public:
|
2020-06-29 11:48:06 +03:00
|
|
|
explicit ImageUploader(QObject *parent = nullptr);
|
2017-07-06 01:59:00 +03:00
|
|
|
~ImageUploader();
|
|
|
|
|
|
|
|
Q_INVOKABLE void setFile(const QString &fileName);
|
|
|
|
Q_INVOKABLE void setAuthorizationHeader(const QString &authorizationHeader);
|
2017-07-06 12:22:12 +03:00
|
|
|
Q_INVOKABLE void setUploadUrl(const QString &userAgent);
|
2017-07-06 01:59:00 +03:00
|
|
|
Q_INVOKABLE void setParameters(const QString &album, const QString &title, const QString &description);
|
|
|
|
Q_INVOKABLE void upload();
|
|
|
|
|
|
|
|
qreal progress() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void success(const QString &replyData);
|
|
|
|
void failure(const int status, const QString &statusText);
|
|
|
|
void progressChanged();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
|
|
|
|
void replyFinished();
|
|
|
|
|
|
|
|
private:
|
|
|
|
qreal m_progress;
|
|
|
|
QNetworkAccessManager *m_networkAccessManager;
|
|
|
|
|
|
|
|
QString m_fileName;
|
|
|
|
QByteArray m_authorizationHeader;
|
2017-07-06 12:22:12 +03:00
|
|
|
QString m_uploadUrl;
|
2017-07-06 01:59:00 +03:00
|
|
|
QByteArray postdata;
|
|
|
|
QNetworkReply *m_reply;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // IMAGEUPLOADER_H
|