1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-27 22:18:36 +02:00
Files
OpenIntegrations/docs/en/md/OpenAI/File-management/Upload-file.mdx

88 lines
2.8 KiB
Plaintext
Raw Normal View History

2025-06-07 18:34:45 +03:00
---
sidebar_position: 2
description: Upload file and other functions to work with OpenAI 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, OpenAI]
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Upload file
Uploads a file for further use in other requests
`Function UploadFile(Val URL, Val Token, Val FileName, Val Data, Val Destination, Val AdditionalHeaders = "") Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| URL | --url | String | ✔ | OpenAI server URL |
| Token | --token | String | ✔ | OpenAI authorization token |
| FileName | --name | String | ✔ | File name with extension |
| Data | --data | String, BinaryData | ✔ | Path to file or data |
| Destination | --purpose | String | ✔ | File purpose: assistants, batch, vision, user_data, evals |
| AdditionalHeaders | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
Returns: Map Of KeyAndValue - Processing result
<br/>
:::tip
Method at API documentation: [Upload file](https://platform.openai.com/docs/api-reference/files/create)
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
URL = "https://hut.openintegrations.dev/localai/";
Token = "12We...";
2025-06-07 18:34:45 +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-06-13 08:51:43 +03:00
FileName = StrTemplate("%1.png", String(New UUID()));
2025-06-07 18:34:45 +03:00
Destination = "assistants";
Result = OPI_OpenAI.UploadFile(URL, Token, FileName, File, Destination);
```
2025-06-18 21:53:54 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint openai UploadFile \
2025-07-04 23:24:42 +03:00
--url "https://hut.openintegrations.dev/localai/" \
2025-06-18 21:53:54 +03:00
--token "***" \
2025-10-15 14:32:00 +03:00
--name "a9f046c2-2403-46ae-af3c-de688d8c5722.png" \
2025-07-04 23:24:42 +03:00
--data "https://hut.openintegrations.dev/test_data/picture.jpg" \
2025-06-18 21:53:54 +03:00
--purpose "assistants"
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint openai UploadFile ^
2025-07-04 23:24:42 +03:00
--url "https://hut.openintegrations.dev/localai/" ^
2025-06-18 21:53:54 +03:00
--token "***" ^
2025-10-15 14:32:00 +03:00
--name "a9f046c2-2403-46ae-af3c-de688d8c5722.png" ^
2025-07-04 23:24:42 +03:00
--data "https://hut.openintegrations.dev/test_data/picture.jpg" ^
2025-06-18 21:53:54 +03:00
--purpose "assistants"
```
</TabItem>
</Tabs>
2025-06-07 18:34:45 +03:00
2025-06-17 16:20:59 +03:00
```json title="Result"
{
2025-09-16 09:07:33 +03:00
"id": "file-12",
2025-06-17 16:20:59 +03:00
"object": "file",
"bytes": 2114025,
2025-09-16 09:07:33 +03:00
"created_at": "2025-09-16T00:27:13.526537069Z",
"filename": "4ab5d04d-4296-4572-a912-f2334a88a5c9.png",
2025-06-17 16:20:59 +03:00
"purpose": "assistants"
}
```