1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-12-05 22:53:35 +02:00
Files
OpenIntegrations/docs/en/md/Bitrix24/File-management/Upload-file-to-storage.mdx

120 lines
4.0 KiB
Plaintext
Raw Normal View History

2024-10-15 10:50:56 +03:00
---
2024-10-15 10:16:04 +03:00
sidebar_position: 1
2025-05-05 11:15:20 +03:00
description: Upload file to a storage 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
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, Bitrix24]
2024-10-15 10:16:04 +03:00
---
2024-10-15 10:50:56 +03:00
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
2024-10-15 10:16:04 +03:00
# Upload file to a storage
Upload file to storage root
`Function UploadFileToStorage(Val URL, Val Name, Val File, Val StorageID, Val Rights = "", Val Token = "") Export`
2024-10-15 15:15:47 +03:00
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| URL | --url | String | ✔ | URL of webhook or a Bitrix24 domain, when token used |
| Name | --title | String | ✔ | File name with extension |
| File | --file | String, BinaryData | ✔ | File for upload |
| StorageID | --storageid | String | ✔ | Storage id |
| Rights | --rights | String | ✖ | Rights array if required |
| Token | --token | String | ✖ | Access token, when app auth method used |
2024-10-15 10:16:04 +03:00
Returns: Map Of KeyAndValue - serialized JSON of answer from Bitrix24 API
<br/>
:::tip
2024-11-21 14:55:35 +03:00
Method at API documentation: [disk.storage.uploadfile](https://dev.1c-bitrix.ru/rest_help/disk/storage/disk_storage_uploadfile.php)
2024-10-15 13:51:58 +03:00
Parameters with Binary data type can also accept file paths on disk and URLs
2024-10-15 10:16:04 +03:00
:::
<br/>
2024-12-16 19:38:57 +03:00
2024-10-15 21:15:56 +03:00
```bsl title="1C:Enterprise/OneScript code example"
2024-10-15 10:16:04 +03:00
Filename2 = "Picture2.jpg";
Name = "Picture1.jpg";
2025-06-29 14:35:33 +03:00
Image2 = "https://hut.openintegrations.dev/test_data/picture.jpg"; // Local path, URL or Binary Data
Image = "https://hut.openintegrations.dev/test_data/picture2.jpg"; // Local path, URL or Binary Data
2024-10-15 10:16:04 +03:00
DestinationID = 3;
2025-06-29 14:35:33 +03:00
URL = "https://b24-ar17wx.bitrix24.by/rest/1/h0m...";
2024-10-15 10:16:04 +03:00
Result = OPI_Bitrix24.UploadFileToStorage(URL, Filename2, Image2, DestinationID);
2025-06-29 14:35:33 +03:00
URL = "b24-ar17wx.bitrix24.by";
2025-09-12 16:37:40 +03:00
Token = "7a1ec468006e9f06006b12e400000001000...";
2024-10-15 10:16:04 +03:00
Result = OPI_Bitrix24.UploadFileToStorage(URL, Name, Image, DestinationID, , Token);
```
2024-10-20 22:36:03 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint bitrix24 UploadFileToStorage \
2024-10-22 08:59:24 +03:00
--url "b24-ar17wx.bitrix24.by" \
--title "Picture1.jpg" \
2025-07-05 18:56:59 +03:00
--file "https://hut.openintegrations.dev/test_data/picture2.jpg" \
2024-10-22 08:59:24 +03:00
--storageid 3 \
--token "***"
2024-10-20 22:36:03 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint bitrix24 UploadFileToStorage ^
2024-10-22 08:59:24 +03:00
--url "b24-ar17wx.bitrix24.by" ^
--title "Picture1.jpg" ^
2025-07-05 18:56:59 +03:00
--file "https://hut.openintegrations.dev/test_data/picture2.jpg" ^
2024-10-22 08:59:24 +03:00
--storageid 3 ^
--token "***"
2024-10-20 22:36:03 +03:00
```
</TabItem>
</Tabs>
2024-10-15 10:16:04 +03:00
```json title="Result"
{
"result": {
2025-09-12 20:23:31 +03:00
"ID": 41952,
2024-10-15 10:16:04 +03:00
"NAME": "Picture1.jpg",
"CODE": null,
"STORAGE_ID": "3",
"TYPE": "file",
"PARENT_ID": "3",
"DELETED_TYPE": 0,
"GLOBAL_CONTENT_VERSION": 1,
2025-09-12 20:23:31 +03:00
"FILE_ID": 28138,
2024-10-15 10:16:04 +03:00
"SIZE": "805189",
2025-09-12 20:23:31 +03:00
"CREATE_TIME": "2025-09-12T16:38:08+00:00",
"UPDATE_TIME": "2025-09-12T16:38:08+00:00",
2024-10-15 10:16:04 +03:00
"DELETE_TIME": null,
"CREATED_BY": "1",
"UPDATED_BY": "1",
"DELETED_BY": null,
2025-09-12 20:23:31 +03:00
"DOWNLOAD_URL": "https://b24-ar17wx.bitrix24.by/rest/download.json?auth=1c5ac468006e9f06006b12e400000001000007cd52acde92bcfe2663bdaff09586a2ce&token=disk%7CaWQ9NDE5NTImXz0wQXR0dm1BTjRKZUE4MVQ5aFhPYWo5QjR3eWhQSXFRMg%3D%3D%7CImRvd25sb2FkfGRpc2t8YVdROU5ERTVOVEltWHowd1FYUjBkbTFCVGpSS1pVRTRNVlE1YUZoUFlXbzVRalIzZVdoUVNYRlJNZz09fDFjNWFjNDY4MDA2ZTlmMDYwMDZiMTJlNDAwMDAwMDAxMDAwMDA3Y2Q1MmFjZGU5MmJjZmUyNjYzYmRhZmYwOTU4NmEyY2Ui.d3TKnfFKBMn2Ildzt7gz9Zb96DHHHo7EGZbJ05kwkyQ%3D",
2024-10-15 10:16:04 +03:00
"DETAIL_URL": "https://b24-ar17wx.bitrix24.by/docs/file/Picture1.jpg"
},
"time": {
2025-09-12 20:23:31 +03:00
"start": 1757695088.39809,
"finish": 1757695088.61025,
"duration": 0.212157011032104,
"processing": 0.181737899780273,
"date_start": "2025-09-12T16:38:08+00:00",
"date_finish": "2025-09-12T16:38:08+00:00",
"operating_reset_at": 1757695688,
"operating": 0.181717872619629
2024-10-15 10:16:04 +03:00
}
}
```