You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-29 22:27:42 +02:00
174 lines
5.8 KiB
Plaintext
Vendored
174 lines
5.8 KiB
Plaintext
Vendored
---
|
|
sidebar_position: 5
|
|
description: Send file and other functions to work with Bitrix24 in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
|
|
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Bitrix24]
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
# Send file
|
|
Send disk file to chat
|
|
|
|
|
|
|
|
`Function SendFile(Val URL, Val ChatID, Val FileID, Val Description = "", Val Token = "") Export`
|
|
|
|
| Parameter | CLI option | Type | Required | Description |
|
|
|-|-|-|-|-|
|
|
| URL | --url | String | ✔ | URL of webhook or a Bitrix24 domain, when token used |
|
|
| ChatID | --chat | String, Number | ✔ | Chat ID |
|
|
| FileID | --fileid | String, Number | ✔ | File ID from UploadFileToFolder method |
|
|
| Description | --description | String | ✖ | File description |
|
|
| Token | --token | String | ✖ | Access token, when app auth method used |
|
|
|
|
|
|
Returns: Map Of KeyAndValue - serialized JSON of answer from Bitrix24 API
|
|
|
|
<br/>
|
|
|
|
:::tip
|
|
Method at API documentation: [im.disk.file.commit](https://dev.1c-bitrix.ru/learning/course/index.php?COURSE_ID=93&LESSON_ID=11485)
|
|
:::
|
|
<br/>
|
|
|
|
|
|
|
|
```bsl title="1C:Enterprise/OneScript code example"
|
|
URL = "https://b24-ar17wx.bitrix24.by/rest/1/h0m...";
|
|
ChatID = "3040";
|
|
File = "https://hut.openintegrations.dev/test_data/document.docx"; // Binary Data, URL or path to file
|
|
Description = "Very important file";
|
|
|
|
Directory = OPI_Bitrix24.GetChatFilesFolder(URL, ChatID);
|
|
FolderID = Directory["result"]["ID"];
|
|
|
|
UploadedFile = OPI_Bitrix24.UploadFileToFolder(URL, "Imortant doc.docx", File, FolderID);
|
|
FileID = UploadedFile["result"]["ID"];
|
|
|
|
Result = OPI_Bitrix24.SendFile(URL, ChatID, FileID, Description);
|
|
|
|
URL = "b24-ar17wx.bitrix24.by";
|
|
Token = "7a1ec468006e9f06006b12e400000001000...";
|
|
ChatID = "3042";
|
|
|
|
Directory = OPI_Bitrix24.GetChatFilesFolder(URL, ChatID, Token);
|
|
FolderID = Directory["result"]["ID"];
|
|
|
|
UploadedFile = OPI_Bitrix24.UploadFileToFolder(URL, "Imortant doc.docx", File, FolderID, Token);
|
|
FileID = UploadedFile["result"]["ID"];
|
|
|
|
Result = OPI_Bitrix24.SendFile(URL, ChatID, FileID, Description, Token);
|
|
```
|
|
|
|
|
|
<Tabs>
|
|
|
|
<TabItem value="bash" label="Bash" default>
|
|
```bash
|
|
oint bitrix24 SendFile \
|
|
--url "b24-ar17wx.bitrix24.by" \
|
|
--chat 2810 \
|
|
--fileid 39148 \
|
|
--description "Very important file" \
|
|
--token "***"
|
|
```
|
|
</TabItem>
|
|
|
|
<TabItem value="bat" label="CMD/Bat" default>
|
|
```batch
|
|
oint bitrix24 SendFile ^
|
|
--url "b24-ar17wx.bitrix24.by" ^
|
|
--chat 2810 ^
|
|
--fileid 39148 ^
|
|
--description "Very important file" ^
|
|
--token "***"
|
|
```
|
|
</TabItem>
|
|
</Tabs>
|
|
|
|
|
|
```json title="Result"
|
|
{
|
|
"result": {
|
|
"FILES": {
|
|
"upload42092": {
|
|
"id": 42092,
|
|
"chatId": 3054,
|
|
"date": {},
|
|
"type": "file",
|
|
"name": "Imortant doc.docx",
|
|
"extension": "docx",
|
|
"size": 24071,
|
|
"image": false,
|
|
"status": "done",
|
|
"progress": 100,
|
|
"authorId": 1,
|
|
"authorName": "Антон Титовец",
|
|
"urlPreview": "",
|
|
"urlShow": "https://b24-ar17wx.bitrix24.by/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=42092&width=1280&height=1280&signature=965f03958f60b19f3709605e62421d7e7b85f90d6a2a6c81bd8d5425ac122026&exact=N&fileName=Imortant%20doc.docx",
|
|
"urlDownload": "https://b24-ar17wx.bitrix24.by/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=42092&width=1280&height=1280&signature=965f03958f60b19f3709605e62421d7e7b85f90d6a2a6c81bd8d5425ac122026&exact=N&fileName=Imortant%20doc.docx",
|
|
"viewerAttrs": {
|
|
"viewer": null,
|
|
"viewerType": "cloud-document",
|
|
"src": "https://b24-ar17wx.bitrix24.by/bitrix/services/main/ajax.php?action=disk.api.file.download&SITE_ID=s1&humanRE=1&fileId=42092&width=1280&height=1280&signature=965f03958f60b19f3709605e62421d7e7b85f90d6a2a6c81bd8d5425ac122026&exact=N&fileName=Imortant%20doc.docx",
|
|
"viewerTypeClass": "BX.Messenger.Integration.Viewer.OnlyOfficeChatItem",
|
|
"viewerSeparateItem": true,
|
|
"viewerExtension": "im.integration.viewer",
|
|
"objectId": "42092",
|
|
"imChatId": 3054,
|
|
"title": "Imortant doc.docx",
|
|
"actions": "[{\"type\":\"download\"},{\"type\":\"copyToMe\",\"text\":\"Сохранить на Диск\",\"action\":\"BXIM.disk.saveToDiskAction\",\"params\":{\"fileId\":\"42092\"},\"extension\":\"disk.viewer.actions\",\"buttonIconClass\":\"ui-btn-icon-cloud\"}]"
|
|
},
|
|
"mediaUrl": {
|
|
"preview": {
|
|
"250": ""
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"DISK_ID": [
|
|
"42092"
|
|
],
|
|
"FILE_MODELS": {
|
|
"upload42092": {
|
|
"id": 42092,
|
|
"name": "Imortant doc.docx",
|
|
"createTime": {},
|
|
"updateTime": {},
|
|
"deleteTime": null,
|
|
"code": null,
|
|
"xmlId": null,
|
|
"storageId": 6,
|
|
"realObjectId": 42092,
|
|
"parentId": 42088,
|
|
"deletedType": 0,
|
|
"createdBy": "1",
|
|
"updatedBy": "1",
|
|
"deletedBy": "0",
|
|
"typeFile": 4,
|
|
"globalContentVersion": 2,
|
|
"fileId": 28234,
|
|
"size": 24071,
|
|
"etag": "b8d93eaebd8d027f138d2963bd80bed7",
|
|
"links": {
|
|
"download": "/bitrix/services/main/ajax.php?action=disk.file.download&SITE_ID=s1&fileId=42092",
|
|
"showInGrid": "/bitrix/tools/disk/focus.php?objectId=42092&action=showObjectInGrid&ncc=1"
|
|
}
|
|
}
|
|
},
|
|
"MESSAGE_ID": 60070
|
|
},
|
|
"time": {
|
|
"start": 1757849505.53248,
|
|
"finish": 1757849505.58389,
|
|
"duration": 0.0514090061187744,
|
|
"processing": 0.0256760120391846,
|
|
"date_start": "2025-09-14T11:31:45+00:00",
|
|
"date_finish": "2025-09-14T11:31:45+00:00",
|
|
"operating_reset_at": 1757850105,
|
|
"operating": 0
|
|
}
|
|
}
|
|
```
|