tgbot-cpp
Loading...
Searching...
No Matches
InputFile.h
Go to the documentation of this file.
1#pragma once
2
3#include "tgbot/export.h"
4
5#include <memory>
6#include <optional>
7#include <string>
8#include <string_view>
9
10namespace TgBot {
11
18 using Ptr = std::shared_ptr<InputFile>;
19
25 std::string data;
26
30 std::string mimeType;
31
35 std::string fileName;
36
43 std::optional<std::string> filePath;
44
52 static std::shared_ptr<InputFile> fromData(std::string data, std::string mimeType, std::string fileName);
53
64 static std::shared_ptr<InputFile> fromFile(std::string_view filePath, std::string mimeType);
65};
66
76 std::string name;
77
81 std::shared_ptr<InputFile> file;
82};
83
84} // namespace TgBot
#define TGBOT_API
Definition export.h:5
Definition Api.h:18
A named multipart file referenced from a Telegram API argument as attach://name.
Definition InputFile.h:72
std::string name
Multipart form field name used in the attach:// reference.
Definition InputFile.h:76
std::shared_ptr< InputFile > file
File contents to upload under the specified name.
Definition InputFile.h:81
This object represents the contents of a file to be uploaded.
Definition InputFile.h:17
std::string mimeType
Mime type of the contents.
Definition InputFile.h:30
std::string data
Contents used for an in-memory upload.
Definition InputFile.h:25
static std::shared_ptr< InputFile > fromData(std::string data, std::string mimeType, std::string fileName)
Creates new std::shared_ptr<InputFile> from binary data held in memory.
std::shared_ptr< InputFile > Ptr
Definition InputFile.h:18
std::optional< std::string > filePath
Local path used for a streaming upload.
Definition InputFile.h:43
std::string fileName
File name.
Definition InputFile.h:35
static std::shared_ptr< InputFile > fromFile(std::string_view filePath, std::string mimeType)
Creates new std::shared_ptr<InputFile> from an existing file.