1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-23 22:05:15 +02:00
Files
OpenIntegrations/docs/en/md/GreenAPI/Message-sending/Send-file.mdx

93 lines
3.5 KiB
Plaintext
Raw Normal View History

2025-03-06 23:26:18 +03:00
---
sidebar_position: 2
2025-10-26 19:20:16 +03:00
description: Send file and other functions to work with GreenAPI 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, GreenAPI]
2025-03-06 23:26:18 +03:00
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Send file
Sends the file to the selected chat room
`Function SendFile(Val AccessParameters, Val ChatID, Val File, Val FileName, Val Description = "", Val ReplyID = "") Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| AccessParameters | --access | Structure Of KeyAndValue | ✔ | Access parameters. See FormAccessParameters |
| ChatID | --chat | String | ✔ | Chat identifier |
| File | --file | String, BinaryData | ✔ | File data or filepath |
| FileName | --filename | String | ✔ | Name of the file with the extension |
| Description | --caption | String | ✖ | Message text below the file |
| ReplyID | --quoted | String | ✖ | Replying message id if necessary |
Returns: Map Of KeyAndValue - serialized JSON response from Green API
<br/>
:::tip
Method at API documentation: [SendFileByUpload](https://green-api.com/docs/api/sending/SendFileByUpload/)
Parameters with Binary data type can also accept file paths on disk and URLs
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
2025-10-21 11:36:43 +03:00
ApiUrl = "https://7105.api.greenapi.com";
MediaUrl = "https://7105.media.greenapi.com";
IdInstance = "71051...";
ApiTokenInstance = "425010d90e114aa6b78f0969e...";
2025-03-06 23:26:18 +03:00
2025-10-21 11:36:43 +03:00
File = "https://hut.openintegrations.dev/test_data/picture.jpg"; // URL, Path or Binary Data
2025-03-06 23:26:18 +03:00
FileName = "photo.jpg";
2025-10-21 11:36:43 +03:00
ChatID = "120363410406221140@g.us";
2025-03-06 23:26:18 +03:00
Description = "File description";
AccessParameters = OPI_GreenAPI.FormAccessParameters(ApiUrl, MediaUrl, IdInstance, ApiTokenInstance);
Result = OPI_GreenAPI.SendFile(AccessParameters, ChatID, File, FileName, Description);
```
2025-03-18 11:35:12 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
2025-10-10 09:59:43 +03:00
# JSON data can also be passed as a path to a .json file
2025-03-18 11:35:12 +03:00
oint greenapi SendFile \
--access "{'apiUrl':'***','mediaUrl':'https://7105.media.greenapi.com','idInstance':'7105187566','apiTokenInstance':'***'}" \
--chat "120363410406221140@g.us" \
2025-07-05 18:56:59 +03:00
--file "https://hut.openintegrations.dev/test_data/video.mp4" \
2025-03-18 11:35:12 +03:00
--filename "vid.mp4" \
--caption "File description" \
2025-10-31 15:42:42 +03:00
--quoted "BAE567CCD78F0903"
2025-03-18 11:35:12 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
2025-10-10 09:59:43 +03:00
:: JSON data can also be passed as a path to a .json file
2025-03-18 11:35:12 +03:00
oint greenapi SendFile ^
--access "{'apiUrl':'***','mediaUrl':'https://7105.media.greenapi.com','idInstance':'7105187566','apiTokenInstance':'***'}" ^
--chat "120363410406221140@g.us" ^
2025-07-05 18:56:59 +03:00
--file "https://hut.openintegrations.dev/test_data/video.mp4" ^
2025-03-18 11:35:12 +03:00
--filename "vid.mp4" ^
--caption "File description" ^
2025-10-31 15:42:42 +03:00
--quoted "BAE567CCD78F0903"
2025-03-18 11:35:12 +03:00
```
</TabItem>
</Tabs>
2025-03-06 23:26:18 +03:00
2025-03-18 10:00:47 +03:00
```json title="Result"
{
2025-10-31 15:42:42 +03:00
"idMessage": "BAE596C4E4224C82",
"urlFile": "https://do-mediaout-7105.fra1.digitaloceanspaces.com/7105187566/5d9c7727-cc32-4016-99c5-aba88e6b1fa9.jpg"
2025-03-18 10:00:47 +03:00
}
```