-
Notifications
You must be signed in to change notification settings - Fork 267
Expand file tree
/
Copy pathInputFile.cpp
More file actions
30 lines (22 loc) · 804 Bytes
/
Copy pathInputFile.cpp
File metadata and controls
30 lines (22 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "tgbot/InputFile.h"
#include <filesystem>
#include <memory>
#include <string>
#include <utility>
namespace TgBot {
std::shared_ptr<InputFile> InputFile::fromData(std::string data, std::string mimeType, std::string fileName) {
auto result = std::make_shared<InputFile>();
result->data = std::move(data);
result->mimeType = std::move(mimeType);
result->fileName = std::move(fileName);
return result;
}
std::shared_ptr<InputFile> InputFile::fromFile(std::string_view filePath, std::string mimeType) {
const std::filesystem::path path(filePath);
auto result(std::make_shared<InputFile>());
result->mimeType = std::move(mimeType);
result->fileName = path.filename().string();
result->filePath = path.string();
return result;
}
} // namespace TgBot