9#include <QJsonDocument>
15 const QString &fileName,
16 const QString &fileType,
17 const QByteArray& data,
24 for (
auto it = extraObjects.begin(); it != extraObjects.end(); it = std::next(it)) {
25 addArg(it.key(), QJsonDocument(*it.value()).toJson(QJsonDocument::Compact));
32 const QFileInfo &file,
34 const QHash<QString, QSharedPointer<QJsonObject> > &extraObjects):
37 QFile readFile(file.absoluteFilePath());
38 if (!readFile.open(QIODevice::ReadOnly)) {
39 qWarning() <<
"Fail to open file" << file.absoluteFilePath();
42 for (
auto it = extraObjects.begin(); it != extraObjects.end(); it = std::next(it)) {
43 addArg(it.key(), QJsonDocument(*it.value()).toJson(QJsonDocument::Compact));
46 auto&& sufix = file.suffix();
47 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
void addArg(const QString &key, const QVariant &val)
addArg This method push new arg, to arguments list
#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