9#include <QJsonDocument>
15 const QString &fileName,
16 const QString &fileType,
17 const QByteArray& data,
25 for (
auto it = extraObjects.begin(); it != extraObjects.end(); it = std::next(it)) {
26 addArg(it.key(), QJsonDocument(*it.value()).toJson(QJsonDocument::Compact));
33 const QFileInfo &file,
35 const QHash<QString, QSharedPointer<QJsonObject> > &extraObjects):
39 QFile readFile(file.absoluteFilePath());
40 if (!readFile.open(QIODevice::ReadOnly)) {
41 qWarning() <<
"Fail to open file" << file.absoluteFilePath();
44 for (
auto it = extraObjects.begin(); it != extraObjects.end(); it = std::next(it)) {
45 addArg(it.key(), QJsonDocument(*it.value()).toJson(QJsonDocument::Compact));
48 auto&& sufix = file.suffix();
49 if (sufix.contains(
"png") || sufix.contains(
"jpg") || sufix.contains(
"jepg") || sufix.contains(
"gif")) {
RequestMethod method() const override
method returns method of the request.
TelegramSendFile(const QString &request, const QString &fileName, const QString &fileType, const QByteArray &data, const TelegramArgs &args, const QHash< QString, QSharedPointer< QJsonObject > > &extraObjects={})
virtual QString type() const
type return type file. By Default it is REQUEST_UPLOAD_FILE_KEY
The TelegramSingleRquest class Is base class for all single requests commands with arguments.
RequestMethod
RequestMethod Tgis islist of supported requests types of the requests.
@ Upload
this is post request to upload a big data to telegram
const QMap< QString, QVariant > & args() const
args This method returns a current list of arguments
void addArg(const QString &key, const QVariant &val)
addArg This method push new arg, to arguments list
void setPriority(RequestPriority newPriority)
#define REQUEST_UPLOAD_FILE_KEY
QHash< QString, QSharedPointer< QJsonObject > > ExtraJsonObjects
ExtraJsonObjects hash map of the extra objects of the message.
The TelegramArgs class is base structure for the all tellegram message arguments.
#define TELEGRAM_DOCUMENT