Skip to main content

Send file

Sends the file to the chat

Function SendFile(Val Token, Val ChatID, Val File, Val Text = "", Val FileName = "", Val Markup = "MarkdownV2") Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringBot token
ChatID--chatidString, NumberChat ID for sending
File--fileBinaryData, StringFile for sending
Text--textStringFile caption
FileName--filenameStringDisplayed file name
Markup--parsemodStringMarkup type for message text: MarkdownV2 or HTML

Returns: Map Of KeyAndValue - serialized JSON response from VK Teams


tip

Method at API documentation: POST /messages/sendFile
Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
    Token  = "001.3501506236.091...";
ChatID = "AoLI0egLWBSLR1Ngn2w";
Text = "File caption";

File = "https://api.athenaeum.digital/test_data/document.docx"; // URL
FilePath = GetTempFileName("docx"); // Path

CopyFile(File, FilePath);

FileBD = New BinaryData(FilePath); // Binary

Result = OPI_VKTeams.SendFile(Token, ChatID, File);

Result = OPI_VKTeams.SendFile(Token, ChatID, FilePath, Text);

Result = OPI_VKTeams.SendFile(Token, ChatID, FileBD, Text, "ImportantDocument.docx");
    oint vkteams SendFile \
--token "***" \
--chatid "AoLI0egLWBSLR1Ngn2w" \
--file "C:\Users\Administrator\AppData\Local\Temp\d3ro54fx1c1.tmp" \
--text "File caption" \
--filename "ImportantDocument.docx"
Result
{
"fileId": "UevBE3dRlqHftBiESLglDn670621531bd",
"msgId": "7423657676132845883",
"ok": true
}