tgbot-cpp
Loading...
Searching...
No Matches
TgBot::InputFile Struct Reference

This object represents the contents of a file to be uploaded. More...

#include <InputFile.h>

Public Types

using Ptr = std::shared_ptr<InputFile>

Static Public Member Functions

static std::shared_ptr< InputFilefromData (std::string data, std::string mimeType, std::string fileName)
 Creates new std::shared_ptr<InputFile> from binary data held in memory.
static std::shared_ptr< InputFilefromFile (std::string_view filePath, std::string mimeType)
 Creates new std::shared_ptr<InputFile> from an existing file.

Public Attributes

std::string data
 Contents used for an in-memory upload.
std::string mimeType
 Mime type of the contents.
std::string fileName
 File name.
std::optional< std::string > filePath
 Local path used for a streaming upload.

Detailed Description

This object represents the contents of a file to be uploaded.

Definition at line 17 of file InputFile.h.

Member Typedef Documentation

◆ Ptr

using TgBot::InputFile::Ptr = std::shared_ptr<InputFile>

Definition at line 18 of file InputFile.h.

Member Function Documentation

◆ fromData()

std::shared_ptr< InputFile > TgBot::InputFile::fromData ( std::string data,
std::string mimeType,
std::string fileName )
static

Creates new std::shared_ptr<InputFile> from binary data held in memory.

Parameters
dataFile contents. May contain null bytes.
mimeTypeMime type of the file.
fileNameFile name reported in the multipart upload.

◆ fromFile()

std::shared_ptr< InputFile > TgBot::InputFile::fromFile ( std::string_view filePath,
std::string mimeType )
static

Creates new std::shared_ptr<InputFile> from an existing file.

Stores the path without reading the file. The HTTP client streams its contents during the request and uses the basename of filePath as the multipart file name. The file must remain accessible and unchanged until the request completes.

Parameters
filePathPath to the file to stream.
mimeTypeMime type of the file.

Member Data Documentation

◆ data

std::string TgBot::InputFile::data

Contents used for an in-memory upload.

Empty for files created with fromFile().

Definition at line 25 of file InputFile.h.

◆ fileName

std::string TgBot::InputFile::fileName

File name.

Definition at line 35 of file InputFile.h.

◆ filePath

std::optional<std::string> TgBot::InputFile::filePath

Local path used for a streaming upload.

When set, the file is read by the HTTP client during the request and data is ignored. The file must remain accessible and unchanged until the request completes.

Definition at line 43 of file InputFile.h.

◆ mimeType

std::string TgBot::InputFile::mimeType

Mime type of the contents.

Definition at line 30 of file InputFile.h.


The documentation for this struct was generated from the following file: