diff options
author | Oleg Morozenkov <reo7sp@users.noreply.github.com> | 2017-01-26 00:32:22 +0300 |
---|---|---|
committer | Oleg Morozenkov <reo7sp@users.noreply.github.com> | 2017-01-26 00:32:22 +0300 |
commit | 85e0e991973594fb458410876a1cc09c5971b918 (patch) | |
tree | 08186c9e9f58cdb617b9b63d583f535b1c884b72 /include | |
parent | 3549754e53f79e9ba0b00fb0bbded5d56a14ef51 (diff) |
Helper method for loading files. Photo upload example. Fixes #24
Diffstat (limited to 'include')
-rw-r--r-- | include/tgbot/tgbot.h | 1 | ||||
-rw-r--r-- | include/tgbot/tools/FileTools.h | 25 | ||||
-rw-r--r-- | include/tgbot/types/InputFile.h | 5 |
3 files changed, 31 insertions, 0 deletions
diff --git a/include/tgbot/tgbot.h b/include/tgbot/tgbot.h index 351410b..a7c8ae6 100644 --- a/include/tgbot/tgbot.h +++ b/include/tgbot/tgbot.h @@ -54,6 +54,7 @@ #include "tgbot/types/InlineQueryResultVideo.h" #include "tgbot/types/ChosenInlineResult.h" #include "tgbot/tools/StringTools.h" +#include "tgbot/tools/FileTools.h" #include "tgbot/net/HttpClient.h" #include "tgbot/net/HttpParser.h" #include "tgbot/net/HttpReqArg.h" diff --git a/include/tgbot/tools/FileTools.h b/include/tgbot/tools/FileTools.h new file mode 100644 index 0000000..6071852 --- /dev/null +++ b/include/tgbot/tools/FileTools.h @@ -0,0 +1,25 @@ +// +// Created by Oleg on 25.01.17. +// + +#ifndef TGBOT_FILETOOLS_H +#define TGBOT_FILETOOLS_H + +#include <string> + +/** + * @ingroup tools + */ +namespace FileTools { + +/** + * Reads whole file to string. + * @param filePath Path to a file + * @return string with file contents + */ +std::string read(const std::string& filePath); + +}; + + +#endif //TGBOT_FILETOOLS_H diff --git a/include/tgbot/types/InputFile.h b/include/tgbot/types/InputFile.h index f2403e3..c56ab7a 100644 --- a/include/tgbot/types/InputFile.h +++ b/include/tgbot/types/InputFile.h @@ -52,6 +52,11 @@ public: * File name. */ std::string fileName; + + /** + * Creates new InputFile::Ptr from an existing file. + */ + static InputFile::Ptr fromFile(const std::string& filePath, const std::string& mimeType); }; } |