Skip to main content

Upload file

Uploads a file to Slack servers

Function UploadFile(Val Token, Val File, Val FileName, Val Title, Val Channel = "") Export

ParameterCLI optionTypeRequiredDescription
Token--tokenStringBot token
File--fileString, BinaryDataFile for upload
FileName--filenameStringFile name with extension
Title--titleStringFile name in Slack
Channel--channelStringChannel ID

Returns: Map Of KeyAndValue - serialized JSON response from Slack


tip

Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
    Token   = "xoxb-6965308400114-696804637...";
Channel = "C06UFNUTKUL";
File = "https://api.athenaeum.digital/test_data/document.docx"; // URL, Binary Data or Path to file

FileName = "megadoc.docx";
Title = "NewFile";

Result = OPI_Slack.UploadFile(Token, File, FileName, Title);

Result = OPI_Slack.UploadFile(Token, File, FileName, Title, Channel);
    oint slack UploadFile \
--token "***" \
--file "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/service/test_data/document.docx" \
--filename "megadoc.docx" \
--title "NewFile" \
--channel "C06UFNUTKUL"
Result
{
"ok": true,
"files": [
{
"id": "F07QV0PCS1L",
"created": 1728454525,
"timestamp": 1728454525,
"name": "megadoc.docx",
"title": "NewFile",
"mimetype": "",
"filetype": "",
"pretty_type": "",
"user": "U06UG1CAYH2",
"user_team": "T06UD92BS3C",
"editable": false,
"size": 24069,
"mode": "hosted",
"is_external": false,
"external_type": "",
"is_public": false,
"public_url_shared": false,
"display_as_bot": false,
"username": "",
"url_private": "https://files.slack.com/files-pri/T06UD92BS3C-F07QV0PCS1L/megadoc.docx",
"url_private_download": "https://files.slack.com/files-pri/T06UD92BS3C-F07QV0PCS1L/download/megadoc.docx",
"media_display_type": "unknown",
"permalink": "https://openintegrationsgroup.slack.com/files/U06UG1CAYH2/F07QV0PCS1L/megadoc.docx",
"permalink_public": "https://slack-files.com/T06UD92BS3C-F07QV0PCS1L-dec85076a5",
"comments_count": 0,
"is_starred": false,
"shares": {},
"channels": [],
"groups": [],
"ims": [],
"has_more_shares": false,
"has_rich_preview": false,
"file_access": "visible"
}
]
}