summaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorOleg Morozenkov <reo7sp@users.noreply.github.com>2017-01-26 00:32:22 +0300
committerOleg Morozenkov <reo7sp@users.noreply.github.com>2017-01-26 00:32:22 +0300
commit85e0e991973594fb458410876a1cc09c5971b918 (patch)
tree08186c9e9f58cdb617b9b63d583f535b1c884b72 /src/types
parent3549754e53f79e9ba0b00fb0bbded5d56a14ef51 (diff)
Helper method for loading files. Photo upload example. Fixes #24
Diffstat (limited to 'src/types')
-rw-r--r--src/types/InputFile.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/types/InputFile.cpp b/src/types/InputFile.cpp
new file mode 100644
index 0000000..0f6cb86
--- /dev/null
+++ b/src/types/InputFile.cpp
@@ -0,0 +1,24 @@
+//
+// Created by Oleg Morozenkov on 25.01.17.
+//
+
+#include "tgbot/types/InputFile.h"
+
+#include <fstream>
+
+#include "tgbot/tools/StringTools.h"
+#include "tgbot/tools/FileTools.h"
+
+using namespace std;
+
+namespace TgBot {
+
+InputFile::Ptr InputFile::fromFile(const string& filePath, const string& mimeType) {
+ InputFile::Ptr result(new InputFile);
+ result->data = FileTools::read(filePath);
+ result->mimeType = mimeType;
+ result->fileName = StringTools::split(filePath, '/').back();
+ return result;
+}
+
+};