KShare/uploaders/default/imguruploader.cpp

22 lines
814 B
C++
Raw Normal View History

2017-04-23 15:05:48 +02:00
#include "imguruploader.hpp"
#include <QBuffer>
#include <QJsonObject>
#include <QJsonValue>
#include <io/ioutils.hpp>
#include <screenshotutil.hpp>
void ImgurUploader::doUpload(QPixmap *pixmap)
{
QByteArray byteArray;
QBuffer buffer(&byteArray);
pixmap->save(&buffer, "PNG");
ioutils::postJson(QUrl("https://api.imgur.com/3/image"),
QList<QPair<QString, QString>>()
2017-04-24 23:14:01 +02:00
<< QPair<QString, QString>("Content-Type", "application/x-www-form-urlencoded")
2017-04-23 15:05:48 +02:00
<< QPair<QString, QString>("Authorization", "Client-ID 8a98f183fc895da"),
2017-04-24 23:14:01 +02:00
byteArray, [](QJsonDocument res, QNetworkReply *) {
2017-04-23 15:05:48 +02:00
screenshotutil::toClipboard(res.object()["data"].toObject()["link"].toString());
});
}